function isDefined(item)
{
	return (typeof item != 'undefined');
}

var gPad = "0000000000";
//by FloP, Friday, May 30, 2003
function getWindowName()
{
	var datNow = new Date();
	var szReturn = "FloPWindows" + datNow.getFullYear();
	szReturn += padItem((datNow.getMonth() + 1));
	szReturn += padItem(datNow.getDate());
	szReturn += padItem(datNow.getHours());
	szReturn += padItem(datNow.getMinutes());
	szReturn += padItem(datNow.getSeconds());
	szReturn += padItem(datNow.getMilliseconds(),3);
	szReturn += padItem(Math.round(Math.random() * 100),3);
	return szReturn;
}
function padItem(intValue,intPad)
{
	if ("number" != typeof(intPad)) intPad = 2;
	var szPad = intValue.toString();
	if (szPad.length < intPad) szPad = gPad.substring(0,intPad - szPad.length) + szPad;
	return szPad;
}
//end FloP

function AddToCart(contextPath,redirect,queryString,imagecode)
{
    var url = contextPath + "/formsubmits/addtocart.html?imagecode="+imagecode+"&redirect="+redirect+"&InitiatedFrom=viewEnlarge";
	if ( queryString!=null && queryString!="" )
		url = url + "&"+queryString;
	window.location = url;
}

function RemoveFromCart(contextPath,redirect,queryString,imagecode)
{
	var url = contextPath + "/formsubmits/removefromcart.html?imagecode="+imagecode+"&redirect="+redirect+"&InitiatedFrom=viewEnlarge";
	if ( queryString!=null && queryString!="" )
		url = url + "&"+queryString;
	window.location = url;
}

function ViewEnlarged(page) {

	window.open(page,"PopUp"+getWindowName() ,"resizable=1,scrollbars=1,toolbar=0,width=880,height=690");
}

function vElg(page, imgcode, redirect, querystring, licType, position) {

    var url = "/search/"+page+"?img="+imgcode;
	if ( position != null ) {
		url += "&offset=" + position ;
	}
	url += "&redirect="+redirect+"&query="+Url.encode(querystring)+"&licType="+licType;
	window.open(url,"PopUp"+getWindowName() ,"resizable=1,scrollbars=1,toolbar=0,width=880,height=690");
}

function vComp(imgcode)
{
    var url = "/search/downloadcomp.html?imagecode="+imgcode;
	window.open(url,"PopUp"+getWindowName() ,"resizable=1,scrollbars=1,toolbar=0,width=436,height=588");
}

function ShowLiveHelp(locale) {
	newWindow = window.open('/uixtracker.html?action=livehelp&r='+ escape('http://enterprise.deeplogicinc.com/cgi-bin/login?queue=2&locale=' + locale + '&sysid=masterfile'),
'customer', 'scrollbars=0,width=455,height=350');
}

function ShowCalc() {
     window.open('/streamTracker.html?sa=Prices&r=https://www1.masterfile.com/ecommerce/priceCalculator.asp&op='+window.location,"PopUp","resizable=1,scrollbars=1,toolbar=1,width=485,height=500");
}

function ShowIntl(page) {
	 window.open(page,"PopUp","resizable=1,scrollbars=1,toolbar=1,width=485,height=254");
}


function ShowPopUp(page) {

	 window.open(page,"PopUp","resizable=1,scrollbars=1,toolbar=1,width=485,height=545");

}




function LightboxAdmin(page, width, height) {

	var frm = document.forms["frmlightboxviewer"];
	if ( frm.sellb != null ) {
	    var selIdx = frm.sellb.selectedIndex;
	    var id = frm.sellb.options[selIdx].value;
	    //if ( id!=0 )
	    page = page + "&selID=" + id;
	}
	//alert(page);
	windowConfig = "resizable=1,scrollbars=0,toolbar=0,width=" + width + ",height=" + height;
	window.open(page,"LightboxAdminPopUp",windowConfig);
}

function hiresDownload(page) {
	window.open(page,"PopUp","resizable=1,scrollbars=0,toolbar=0,width=465,height=300");
}


function RetrievePassword(page) {
	window.open(page,"PopUp","resizable=1,scrollbars=0,toolbar=0,width=465,height=325");
}


function openBookMark() {
 var h = location.hash;
 if (h == "") h = "default";
 if (h == "#") h = "default";
 var ids = h.split(/[#.]/);
 for (i = 0; i < ids.length; i++) {
  if (ids[i] != "") toggle(document.getElementById(ids[i]));
 }
}

// modified by Roger, Jul 30, 2003, for populating catalog order page
function loadCountryProvince(theForm, countryid) {

	var countrySelObj = theForm.countryRegistration;
	var selIdx = 0;
	for ( var i=0; i<countrySelObj.length; i++ )
	{
		if ( countrySelObj.options[i].value == countryid )
		{
			selIdx = i;
			break;
		}
	}

	countrySelObj.options[selIdx].selected = true;
	populateProvince(theForm, countrySelObj.options[selIdx].value);
	var country = countrySelObj.options[selIdx].text;

	if(country=="CANADA"||country=="UNITED STATES")
	{
		var provinceSelObj = theForm.provincestate;
		for ( var j=0; j<provinceSelObj.length; j++ )
		{
			if ( provinceSelObj.options[j].value == theForm.hiddenprovincestate.value )
			{
				selIdx = j;
				break;
			}
		}
		provinceSelObj.options[selIdx].selected = true;
	}
}

function isEmail(string) {
	return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
}

function isName(string)
{
	if ( string.search(/^[-A-Za-z0-9 ._&+=()!?\/,'#"*]+$/) != -1 )
		return true;

	for (var i = 0; i < string.length; i++) {

		var ch = string.charCodeAt(i);

		if ( !(((ch >= 32) && (ch <= 127)) || (((ch >= 192) && (ch <= 255)) && (ch != 0xD7) && (ch != 0xF7))) )
			return false;
	}

	return string.length != 0;
}

function isUserPass(string) {
	return (string.search(/^[-A-Za-z0-9@._]+$/) != -1);
}

function isPhone(string) {
	return (string.search(/^[()-A-Za-z0-9 @._]+$/) != -1);
}

function myDisplayAlert(obj, msg)
{
	alert(msg);
	obj.blur();
	obj.focus();

	return false;
}

function ValidatePageNo(pageObj,lastPage)
{
	var pageNo = pageObj.value;

	if ( pageNo != "" ) {

		var invPos = pageNo.search("[^0-9]");

		if ( invPos == -1 ) {

			if ( pageNo < 1 )
				pageNo = 1;
			else
				if ( pageNo > lastPage )
					pageNo = lastPage;

			pageObj.value = pageNo;

			return true;
		}
		else
			pageObj.value = "";
	}

	return false;
}

function escapeAA(str)
{
	return str.replace(/'/g, "%27").replace(/&/g, "%26");
}

function launchFeatured(featuredURL, windowname, wintype){

    if( wintype == "new" ) {

	 window.open(featuredURL, windowname, "resizable=0,scrollbars=0,toolbar=0,width=740,height=460");

    } else {

	 window.open(featuredURL, windowname, "resizable=0,scrollbars=0,toolbar=0,width=600,height=525");

    }

	// window.open(featuredURL,"FeaturedArtist","resizable=0,scrollbars=0,toolbar=0,width=740,height=460");
}


function launchFeaturedKeyword(featuredkeywordURL){
 window.open(featuredkeywordURL,"featuredkeyword","toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0,status=0,width=800,height=640");
}

function launchCatalog(catalogURL){
 window.open(catalogURL,"unbound","toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0,status=0,width=640,height=505");
}

function launchSideshow(sideshowURL){
 window.open(sideshowURL,"sideshow","toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0,status=0,width=810,height=630");
}

function launchSideshowSmall(sideshowURL){
 window.open(sideshowURL,"sideshow","toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0,status=0,width=650,height=506");
}

function agentsList(selectBox) {

    if (selectBox==null) { selectBox = document.mnu.elements[1]; }
    var preStr = "/info/intl/agents.html#";
    var loc = ((selectBox.options[selectBox.selectedIndex].value).toLowerCase()).replace(/\ /g,"");
    window.location = preStr+loc;
}

// [roger] modified 2004.06.28, for fixing non-refresh function
// codes as below are newer version. the older version has been deleted. if wanna refer to it, please use CVS to veiw hitory
var g_type = new String();
var g_contextPath = new String();
var g_redirect = new String();
var g_queryString = new String();
var g_imagecode = new String();
var g_popup = false;
//var iconImage = new Image();
//var hidImage = new Image();

function afterItemLoaded()
{
    //alert(g_imagecode);
    if ( g_imagecode == "" )
        return;

    //alert(g_type);
    if ( g_type == "addlb" )
        afterAddLBLoaded();
    else if ( g_type == "rmvlb" )
        afterRmvLBLoaded(false);
    else
        return;
}

function iconNotLoaded()
{
    if (g_imagecode=="")
        return;

    if (g_type=="addlb") {
        if (g_popup)
            SubmitAgainEnlargeAction("addtolightbox", g_contextPath, g_queryString, g_imagecode);
        else
            AddToLightbox(g_contextPath,g_redirect,g_queryString,g_imagecode,false);
        return;
    }
    if (g_type=="rmvlb") {
        if (g_popup)
            SubmitAgainEnlargeAction("removefromlightbox", g_contextPath, g_queryString, g_imagecode);
        else
            RemoveFromLightbox(g_contextPath,g_redirect,g_queryString,g_imagecode,false)
        return;
    }
    if (g_type=="addsc") {
        if (g_popup)
            SubmitAgainEnlargeAction("addtocart", g_contextPath, g_queryString, g_imagecode);
        else
            AddToCart(g_contextPath,g_redirect,g_queryString,g_imagecode);
        return;
    }
    if (g_type=="rmvsc") {
        if (g_popup)
            SubmitAgainEnlargeAction("removefromcart", g_contextPath, g_queryString, g_imagecode);
        else
            RemoveFromCart(g_contextPath,g_redirect,g_queryString,g_imagecode);
        return;
    }
}

function SubmitAgainEnlargeAction(action, contextPath, querystring, imagecode)
{
	var url = contextPath+"/formsubmits/"+action+".html?imagecode="+imagecode+"&"+querystring;
	document.location = url;
}

function mSP_flash(imagecode) {

    // test
    var specQuery = ''; // escape(document.special.query.value)
    vElg('enlarged_pricing.html',imagecode,'search',specQuery);
    }

function mEn_flash(imagecode) {

    // test
    var specQuery = ''; // escape(document.special.query.value)
    vElg('enlarged.html',imagecode,'search',specQuery);
    }

function mSS_flash(imagecode) {

    dispatchSimSearch(imagecode) ;
    }

function  callUrl(path,imagecode,popup) {

    var contextPath='';
    var redirect='slideshow';
    var queryString='';

    theWindow = window;

    theWindow.g_contextPath = contextPath;
    theWindow.g_redirect = redirect;
    theWindow.g_queryString = queryString;
    theWindow.g_imagecode = imagecode;

    if (popup != null && popup) {
    window.open('popup',path);
    } else {
    var iconImage = new Image();
	iconImage = new Image();

    dest = contextPath + path + "?imagecode="+imagecode;
    theWindow.g_type = "addsc";
    iconImage.src = dest+"&"+new Date().getTime();
    }

    return false;
    }

function recalculateShoppingCart(win,number){
    var elm = win.document.getElementById("sc_total_count");
    var n = parseInt(elm.innerHTML);
    if (isNaN(n)){
        return;
    }
    var res = n + number;
    if (res < 0){
        res = 0; //prevent shopping cart from being negative number
    }
    elm.innerHTML = new String(res);
}

function mSC(contextPath,redirect,imagecode,popup)
{
    return modCartItem(contextPath,redirect,document.special.queryAdd.value,imagecode,popup);
}


function mSC_flash(contextPath,redirect,imagecode,popup)
{
    return modCartItem_flash(contextPath,redirect,'',imagecode,popup);
}

function modCartItem_flash(contextPath,redirect,queryString,imagecode,popup)
{
    theWindow = window;
    if ( popup ) {
        theWindow = window.opener;
        theWindow.g_popup = popup;
    }

    //theWindow.iconImage = eval("theWindow.document.images['sc"+imagecode+"']");
    theWindow.g_contextPath = contextPath;
    theWindow.g_redirect = redirect;
    theWindow.g_queryString = queryString;
    theWindow.g_imagecode = imagecode;

    var iconImage = eval("document.images['sc"+imagecode+"']"); //used in conditional check, represent the button that is clicked
    //alert(iconImage);

    if (iconImage==null) { // [scosta] April 12, 2006 - to ease slideshow functionality
	// fake an add
	//alert(iconImage);
	iconImage = new Image();
	iconImage.src = "shoppingcart_off.gif";
    }

     if(popup) {
         if ( iconImage.src.indexOf("enlargedimg/addtocart")!=-1 )
         {
             theWindow.g_type = "addsc";
             try {
                 var targetIcon = eval("theWindow.document.images['sc"+imagecode+"']");
                 targetIcon.src = contextPath + "/formsubmits/addtocart.html?imagecode="+imagecode+"&"+new Date().getTime();
             }
             catch(e) {
                 submitEnlargeAction("addtocart", contextPath, queryString, imagecode, false);
             }
             return false;
         }

         if ( iconImage.src.indexOf("enlargedimg/removefromcart")!=-1 )
         {
             theWindow.g_type = "rmvsc";
             try {
                 var targetIcon = eval("theWindow.document.images['sc"+imagecode+"']");
                 targetIcon.src = contextPath + "/formsubmits/removefromcart.html?imagecode="+imagecode+"&"+new Date().getTime();
             }
             catch(e) {
                 submitEnlargeAction("removefromcart", contextPath, queryString, imagecode, false);
             }
             return false;
         }

         return false;
     }

    if ( iconImage.src.indexOf("shoppingcart_off.gif")!=-1 || iconImage.src.indexOf("removefromcart")!=-1 )
    {
        dest = contextPath + "/formsubmits/addtocart.html?imagecode="+imagecode;
        theWindow.g_type = "addsc";
        iconImage.src = dest+"&"+new Date().getTime();
        return false;
    }

    if ( iconImage.src.indexOf("shoppingcart_on.gif")!=-1 || iconImage.src.indexOf("addtocart")!=-1 )
    {
        dest = contextPath + "/formsubmits/removefromcart.html?imagecode="+imagecode;
        theWindow.g_type = "rmvsc";
        iconImage.src = dest+"&"+new Date().getTime();
        return false;
    }

    //theWindow.hidImage = theWindow.document.images["hiddenImage"]; //added by Roger
    //if ( navigator.userAgent.toLowerCase().indexOf("mozilla")!=-1 && parseInt(navigator.appVersion)==5 )
    //    theWindow.hidImage.src = "";
    //
    //theWindow.hidImage.src = dest+"&"+new Date().getTime();
    //alert(dest);

    return false;
}


function modCartItem(contextPath,redirect,queryString,imagecode,popup)
{
    theWindow = window;
    if ( popup ) {
        theWindow = window.opener;
        theWindow.g_popup = popup;
    }

    //theWindow.iconImage = eval("theWindow.document.images['sc"+imagecode+"']");
    theWindow.g_contextPath = contextPath;
    theWindow.g_redirect = redirect;
    theWindow.g_queryString = queryString;
    theWindow.g_imagecode = imagecode;

    var iconImage = eval("document.images['sc"+imagecode+"']"); //used in conditional check, represent the button that is clicked
    //alert(iconImage);

     if(popup) {
         if ( iconImage.src.indexOf("enlargedimg/addtocart")!=-1 )
         {
             theWindow.g_type = "addsc";
             try {
                 var targetIcon = eval("theWindow.document.images['sc"+imagecode+"']");
                 targetIcon.src = contextPath + "/formsubmits/addtocart.html?imagecode="+imagecode+"&InitiatedFrom=viewEnlarge&"+new Date().getTime();
                 window.location.reload();
             }
             catch(e) {
                 submitEnlargeAction("addtocart", contextPath, queryString, imagecode, false);
				 window.document.images['hiddenImage'].src = contextPath + "/formsubmits/addtocart.html?imagecode="+imagecode+"&InitiatedFrom=viewEnlarge&"+new Date().getTime();
             }
			 newLocation = new String(''+window.location).replace(/img=[^&]*/,'img='+imagecode) ;
			 if( newLocation.indexOf( 'hideEnlargedNav') == -1 ) {
				 if( newLocation.charAt(newLocation.length - 1) != '&' && newLocation.charAt(newLocation.length - 1) != ';' ) {
					 newLocation = newLocation + '&' ;
				 }
				 newLocation = newLocation + 'hideEnlargedNav=true' ;
			 }
			 window.location = newLocation ;
             recalculateShoppingCart(theWindow,1);

             if ( redirect == "shoppingcart" ) {
                window.opener.location.reload();
             }

             return true;
         }

         if ( iconImage.src.indexOf("enlargedimg/removefromcart")!=-1 )
         {
             theWindow.g_type = "rmvsc";
             try {
                 var targetIcon = eval("theWindow.document.images['sc"+imagecode+"']");
                 targetIcon.src = contextPath + "/formsubmits/removefromcart.html?imagecode="+imagecode+"&InitiatedFrom=viewEnlarge&"+new Date().getTime();
                 window.location.reload();
             }
             catch(e) {
                 submitEnlargeAction("removefromcart", contextPath, queryString, imagecode, false);
				 window.document.images['hiddenImage'].src = contextPath + "/formsubmits/removefromcart.html?imagecode="+imagecode+"&InitiatedFrom=viewEnlarge&"+new Date().getTime();
             }
			 newLocation = new String(''+window.location).replace(/img=[^&]*/,'img='+imagecode) ;
			 if( newLocation.indexOf( 'hideEnlargedNav') == -1 ) {
				 if( newLocation.charAt(newLocation.length - 1) != '&' && newLocation.charAt(newLocation.length - 1) != ';' ) {
					 newLocation = newLocation + '&' ;
				 }
				 newLocation = newLocation + 'hideEnlargedNav=true' ;
			 }
			 window.location = newLocation ;
             recalculateShoppingCart(theWindow,-1);

             if ( redirect == "shoppingcart" ) {
                window.opener.location.reload();
             }

             return true;
         }

         return true;
     }

    if ( iconImage.src.indexOf("shoppingcart_off.gif")!=-1 || iconImage.src.indexOf("removefromcart")!=-1 )
    {
        if ( redirect == "viewlightbox" )
            InitiatedFrom = "viewLightbox";
        else
            InitiatedFrom = "searchResult";
        
        dest = contextPath + "/formsubmits/addtocart.html?imagecode="+imagecode+"&InitiatedFrom="+InitiatedFrom;
        theWindow.g_type = "addsc";
        iconImage.src = dest+"&"+new Date().getTime();
        recalculateShoppingCart(theWindow,1);
        return false;
    }

    if ( iconImage.src.indexOf("shoppingcart_on.gif")!=-1 || iconImage.src.indexOf("addtocart")!=-1 )
    {
        if ( redirect == "viewlightbox" )
            InitiatedFrom = "viewLightbox";
        else
            InitiatedFrom = "searchResult";

        dest = contextPath + "/formsubmits/removefromcart.html?imagecode="+imagecode+"&InitiatedFrom="+InitiatedFrom;
        theWindow.g_type = "rmvsc";
        iconImage.src = dest+"&"+new Date().getTime();
        recalculateShoppingCart(theWindow,-1);
        return false;
    }

    //theWindow.hidImage = theWindow.document.images["hiddenImage"]; //added by Roger
    //if ( navigator.userAgent.toLowerCase().indexOf("mozilla")!=-1 && parseInt(navigator.appVersion)==5 )
    //    theWindow.hidImage.src = "";
    //
    //theWindow.hidImage.src = dest+"&"+new Date().getTime();
    //alert(dest);

    return false;
}
// [/roger]

// [Scott] - 2004.05.31 - preload Images for icon mouseovers in search results
// Image Swap function for Button Info Labels
// [roger] - 2004.07.16: integrate with non-refresh lightbox function, so roll-over function will detect lb/sc icon in order to determine what message to display
//         - 2004.07.19: localized rollover gif
var imageServer = "";

function setImgServer(imgServer)
{
    imageServer = imgServer;
}

function cImg(imgName,imgSource,lang,whichtype) {
    var type = new String(whichtype);
    if ( type=="undefined" || type=="" )
    {
        if (document.images)
	        document.images[imgName].src = imageServer+"/images/rollovers/"+imgSource;
	    return;
	}

    //alert(type)
    var iconImageSrc = document.images[type+imgName].src;
    //alert(iconImageSrc);
    if( type=="sc" )
    {
        if ( iconImageSrc.indexOf("shoppingcart_off.gif")!=-1 || iconImageSrc.indexOf("removefromcart")!=-1 )
            document.images["r"+imgName].src = imageServer+imgSource+"/images/rollovers/rollover_addto_cart_"+lang+".gif";
        else if ( iconImageSrc.indexOf("shoppingcart_on.gif")!=-1 || iconImageSrc.indexOf("addtocart")!=-1 )
            document.images["r"+imgName].src = imageServer+imgSource+"/images/rollovers/rollover_remove_cart_"+lang+".gif";
    }
    else if ( type=="lb" )
    {
        if ( iconImageSrc.indexOf("lightbox_off.gif")!=-1 || iconImageSrc.indexOf("removefromlightbox")!=-1 )
            document.images["r"+imgName].src = imageServer+imgSource+"/images/rollovers/rollover_addto_lb_"+lang+".gif";
        else if ( iconImageSrc.indexOf("lightbox_on.gif")!=-1 || iconImageSrc.indexOf("addtolightbox")!=-1 )
            document.images["r"+imgName].src = imageServer+imgSource+"/images/rollovers/rollover_removefrom_lb_"+lang+".gif";
    }

}

// [Scott] - 2004.08.27 - use to select the search field by default when pages load
// this is a recommended usability improvement from Terra
// id of searchfield is "searchtext"
// [roger] - 2004.09.15 - modified because popup widnow does not contain element searchtext
function selectSearch() {
	//alert("Select Search is Active.");
    /* Jakub: see LOCA-406 bug for why I'm disabling this
    if(document.forms.length > 0) {
	    if(document.getElementById("searchtext")) //[roger] - 2004.09.17 - check to see whether the window has element searchtext
		    document.getElementById("searchtext").focus(); // set the focus to the search field wherever available
	} else {
		// do nothing
	}*/
}
window.onload = selectSearch;

//javascript on update handler for the most advanced page turner ever :-)
//2007.05.25 Jakub
function newPageJump(sel_field){
    var sel_option;
    for (var i = 0; i < sel_field.options.length; i++){
        if (sel_field.options[i].selected){
            sel_option = sel_field.options[i];
            break;
        }
    }
    if (sel_field.form.url_to.value.indexOf("?") != -1){
        top.location = sel_field.form.url_to.value +"&page="+sel_option.text;
    } else {
        top.location = sel_field.form.url_to.value +"?page="+sel_option.text;
    }
}

function showHideLastSearches(){
    var lastSearchesBody = document.getElementById("search_lastnsearches");
    if (lastSearchesBody.style.display == "none"){
        lastSearchesBody.style.display = "block";
    } else {
        lastSearchesBody.style.display = "none";
    }
}

//DUPLICATE DEFINITION FROM ei/utils.js - I'm sorry I don't know what else to do.
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

//DUPLICATE DEFINITION FROM ei/utils.js - I'm sorry I don't know what else to do.
function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if ((delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}

function EffectFade(div){
    $(div).style.display = "block";
    var confirm = new Fx.Style(div, 'opacity', {duration:1500, transition: Fx.Transitions.quartInOut});
	confirm.start(1,0);
}
                                                                                        
function EffectFadeIn(div,opacity){
    $(div).style.display = "block";
    var opener = new Fx.Style(div, 'opacity', {duration:400, transition: Fx.Transitions.quartInOut});
    opener.addEvent('onComplete',   function() {  $(div).style.display = "none"; } );
    if ( opacity ) {
        opener.start(opacity,0);    
    } else {
        opener.start(1,0);
    }
}

function EffectHighlight(div){
    $(div).style.backgroundColor = "#FFFF00";
//    $(div).style.display = "block";
    var confirm = new Fx.Style(div, 'backgroundColor', {duration:1500, transition: Fx.Transitions.linear});
	confirm.start("#FFFFFF");
}

function EffectFadeToggle(div,opacity){
    if ( $(div).style.display == "block" ) {
        EffectFadeIn (div,opacity);
    } else  {
        EffectFadeOut (div,opacity);
    }
    return false;
}

function EffectFadeOut(div, opacity){
    $(div).setAttribute("style", "opacity:0;")

    if ($(div).style.setAttribute) {//For IE
       $(div).style.setAttribute("filter", "alpha(opacity=0);")
    }
    $(div).style.display = "block";
    var opener = new Fx.Style(div, 'opacity', {duration:400, transition: Fx.Transitions.quartInOut});
    opener.addEvent('onComplete',   function() {  $(div).style.display = "block"; } );
    if ( opacity ) {
        opener.start(0,opacity);
    } else {
        opener.start(0,1);
    }
}

/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/
var Url = {

	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}
}

