//*******************************************************************************
//Title:      FCP Combo-Chromatic Color Picker
//URL:        http://www.free-color-picker.com
//Product No. FCP201a
//Version:    1.2
//Date:       10/01/2006
//NOTE:       Permission given to use this script in ANY kind of applications IF
//            script code remains UNCHANGED and the anchor tag "powered by FCP"
//            remains valid and visible to the user.
//
//  Call:     showColorGrid2("input_field_id","span_id")
//  Add:      <DIV ID="colorpicker" CLASS="colorpicker"></DIV> anywhere in body
//*******************************************************************************
function getScrollY(){var scrOfX = 0,scrOfY=0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}return scrOfY;}document.write("<style type='text/css'>.colorpicker{visibility:hidden;display:none;position:absolute;background:#FFF;border:solid 1px #CCC;padding:4px;z-index:999;filter:progid:DXImageTransform.Microsoft.Shadow(color=#D0D0D0,direction=135);}.o5582brd{padding:0;width:9px;height:10px;border-bottom:solid 1px #DFDFDF;border-right:solid 1px #DFDFDF;}a.o5582n66,.o5582n66,.o5582n66a{font-family:arial,tahoma,sans-serif;text-decoration:underline;font-size:7px;color:#666;border:none;}.o5582n66,.o5582n66a{text-align:center;text-decoration:none;}a:hover.o5582n66{text-decoration:none;color:#FFA500;cursor:pointer;}.a01p3{padding:1px 2px 1px 2px;background:whitesmoke;border:solid 1px #DFDFDF;font-size:7px;}</style>");function getTop2(){csBrHt=0;if(typeof(window.innerWidth)=='number'){csBrHt=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){csBrHt=document.documentElement.clientHeight;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){csBrHt=document.body.clientHeight;}ctop=((csBrHt/2)-115)+getScrollY();return ctop;}var nocol1="clear",clos1="x",tt2="&#70;&#82;&#69;&#69;&#45;&#67;&#79;&#76;&#79;&#82;&#45;&#80;&#73;&#67;&#75;&#69;&#82;&#46;&#67;&#79;&#77;",hm2="&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#119;&#119;&#119;&#46;";hm2+=tt2;tt2="";function getLeft2(){var csBrWt=0;if(typeof(window.innerWidth)=='number'){csBrWt=window.innerWidth;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){csBrWt=document.documentElement.clientWidth;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){csBrWt=document.body.clientWidth;}cleft=(csBrWt/2)-125;return cleft;}function setCCbldID2(objID,val){document.getElementById(objID).value=val;}function setCCbldSty2(objID,prop,val){switch(prop){case "bc":if(objID!='none'){document.getElementById(objID).style.backgroundColor=val;};break;case "vs":document.getElementById(objID).style.visibility=val;break;case "ds":document.getElementById(objID).style.display=val;break;case "tp":document.getElementById(objID).style.top=val;break;case "lf":document.getElementById(objID).style.left=val;break;}}function putOBJxColor2(OBjElem,Samp,pigMent){if(pigMent!='x'){setCCbldID2(OBjElem,pigMent);setCCbldSty2(Samp,'bc',pigMent);}setCCbldSty2('colorpicker','vs','hidden');setCCbldSty2('colorpicker','ds','none');}function showColorGrid2(OBjElem,Sam){var objX=new Array('00','20','40','60','80','A0','C0','E0','F0');var c=0;var z='"'+OBjElem+'","'+Sam+'",""';var xl='"'+OBjElem+'","'+Sam+'","x"';var mid='';mid+='<table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0" style="border:solid 0px #F0F0F0;padding:2px;"><tr>';mid+="<td colspan='18' align='center' style='margin:0;padding:2px;height:10px;' ><input class='o5582n66' type='text' size='10' style='height:10px' id='o5582n66' value='#FFFFFF'><input class='o5582n66a' type='text' size='2' style='width:10px;height:10px' id='o5582n66a' onclick='javascript:alert(\"click on selected swatch below...\");' value='' style='border:solid 1px #666;'>&nbsp;|&nbsp;<a class='o5582n66' href='javascript:onclick=putOBJxColor2("+z+")'><span class='a01p3'>"+nocol1+"</span></a>&nbsp;&nbsp;&nbsp;&nbsp;<a class='o5582n66' href='javascript:onclick=putOBJxColor2("+xl+")'><span class='a01p3'>"+clos1+"</span></a></td></tr><tr>";var br=1;for(o=0;o<9;o++){mid+='</tr><tr>';for(y=0;y<9;y++){if(y==3||y==6){mid+='</tr><tr>';}for(x=0;x<9;x++){var grid='';grid=objX[o]+objX[y]+objX[x];var b="'"+OBjElem+"', '"+Sam+"','#"+grid+"'";mid+='<td class="o5582brd" style="background-color:#'+grid+'"><a class="o5582n66"  href="javascript:onclick=putOBJxColor2('+b+');" onmouseover=javascript:document.getElementById("o5582n66").value="#'+grid+'";javascript:document.getElementById("o5582n66a").style.backgroundColor="#'+grid+'";  title="#'+grid+'"><div style="width:9px;height:10px;"></div></a></td>';c++;}}}mid+="</tr><tr><td colspan='18' align='right' style='padding:2px;border:solid 1px #FFF;background:#FFF;'><a href='"+hm2+"' style='color:#666;font-size:8px;font-family:arial;text-decoration:none;letter-spacing:1px;'>"+tt2+"</a></td></tr></table>";var ttop=getTop2();setCCbldSty2('colorpicker','tp',ttop);document.getElementById('colorpicker').style.left=getLeft2();setCCbldSty2('colorpicker','vs','visible');setCCbldSty2('colorpicker','ds','block');document.getElementById('colorpicker').innerHTML=mid;}

function doAjax_form() {
	var mod = document.filter.mod.value;
	var keyword = document.filter.keyword.value;
	var cid = document.filter.cid.value;
	var ori = document.filter.ori.value;
	var bw = document.filter.bw.value;
	var sort = document.filter.sort.value;
	var y = document.filter.y.value;
	var pr = document.filter.prop_release.checked;
	var mr = document.filter.mod_release.checked;
	component= "mod="+ mod + "&keyword=" + keyword + "&cid=" + cid + "&ori=" + ori + "&bw=" + bw + "&sort=" + sort + "&y=" + y  + "&pr=" + pr + "&mr=" + mr;
	encode=encode64(component);
	doAjax(encode);
}

function show(x) {
	document.getElementById("formadd" + x).style.display="none";
	document.getElementById("wait" + x).style.display="";
}

function doAjax_add(act2,act3,act4) {
	act1=document.getElementById("popID").value;
	url=document.getElementById("reflink").value;
	x=decode64(act1) + "|" + act2 + "|" + act3 + "|" + act4  ;
	doAjax(url,encode64(x));
}

function ToolTip(id,isAnimated,aniSpeed)
{ var isInit = -1;
  var div,divWidth,divHeight;
  var xincr=10,yincr=10;
  var animateToolTip =false;
  var html;
  var ie = document.all ? true : false;
  var w = 0;
  var h = 0;

  function Init(id)
  {
   div = document.getElementById(id);
   if(div==null) return;

   if((div.style.width=="" || div.style.height==""))
   {alert("Both width and height must be set");
   return;}

   divWidth = parseInt(div.style.width);
   divHeight= parseInt(div.style.height);
   if(div.style.overflow!="hidden")div.style.overflow="hidden";
   if(div.style.display!="none")div.style.display="none";
   if(div.style.position!="absolute")div.style.position="absolute";

   if(isAnimated && aniSpeed>0)
   {xincr = parseInt(divWidth/aniSpeed);
    yincr = parseInt(divHeight/aniSpeed);
    animateToolTip = true;
    }

   isInit++;

  }


  this.Show =  function(e,strHTML,popid,pid)
  {
	if (pid) {
		var photo = decode64(pid);
		var photo_array = photo.split("|");
		var prevwidth= parseInt(photo_array[3])+22;
		var des=popid*15;
		var prevheight= parseInt(photo_array[4])+30+des;

		strHTML='<b class="xtop_tp" style="width: ' + prevwidth + 'px;"><b class="xb1_tp"></b><b class="xb2_tp"></b><b class="xb3_tp"></b><b class="xb4_tp"></b></b><div class="xboxcontent_tp" style="text-align:left;"><div class="preview_img" style="width: ' + photo_array[3] + 'px ; height:' + photo_array[4] + 'px;"><img src="' + photo_array[5] + '" alt="'+ photo_array[1] +'" title="'+ photo_array[1] +'" /></div><div style="text-align:left; width: ' + photo_array[3] + 'px"><b>'+ photo_array[1] +'</b><br />'+ photo_array[6] +'</div></div><b class="xbottom_tp" style="width: ' + prevwidth + 'px;"><b class="xb4_tp"></b><b class="xb3_tp"></b><b class="xb2_tp"></b><b class="xb1_tp"></b></b>';
	}else{
    	document.getElementById("popID").value=popid;
    }

    if(isInit<0) return;
    var newPosx,newPosy,height,width;

 	var newPosy_1 = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
	var newPosx_1 = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;

	if(!window.innerWidth) {
		if(!(document.documentElement.clientWidth == 0)){
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}else{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}else{
		w = window.innerWidth;
		h = window.innerHeight;
	}

	var hWnd = {width:0,height:0};
	var offsetX = 0;
	var offsetY = 0;
	if(!window.pageYOffset){
		if(!(document.documentElement.scrollTop == 0)){
			offsetY = document.documentElement.scrollTop;
			offsetX = document.documentElement.scrollLeft;
		}else{
			offsetY = document.body.scrollTop;
			offsetX = document.body.scrollLeft;
		}
	}else{
		offsetX = window.pageXOffset;
		offsetY = window.pageYOffset;
	}
 	if (pid) {

        if (w >= 980){
        	var xstatr= parseInt((w/2)-490);
        	var cell=parseInt(photo_array[0]);
        	var tw= ie ? parseInt(photo_array[2])+22 : parseInt(photo_array[2])+12;
            if (cell<4) {
            	newPosx = xstatr + ((cell-1)*185) + tw;
            }else{
            	newPosx = xstatr + ((cell-1)*185) - (prevwidth+15);
            }
        }else{
         	newPosx = newPosx_1 + 30;
        }

		if ((newPosy_1+prevheight+30+10) > (h+offsetY)) {
			newPosy=newPosy_1-((newPosy_1+prevheight+30+10)- (h+offsetY));
		}else{
        	newPosy = newPosy_1 - 10;
		}
	}else{
 		newPosy = newPosy_1 + 10;
		newPosx = newPosx_1 + 10;
    }

    if(strHTML!=null)
    {html = strHTML;
     div.innerHTML=html;}



    div.style.display='block';
    //debugger;
    //alert(document.body.scrollTop);
    div.style.top= newPosy + "px";
    div.style.left= newPosx+ "px";

    div.focus();
    if(animateToolTip){
    div.style.height= "0px";
    div.style.width= "0px";
    ToolTip.animate(div.id,divHeight,divWidth);}
    }

   this.Hide= function(e)
    {div.style.display='none';
    if(!animateToolTip)return;
    div.style.height= "0px";
    div.style.width= "0px";}

   this.SetHTML = function(strHTML)
   {html = strHTML;
    div.innerHTML=html;}

    ToolTip.animate = function(a,iHeight,iWidth)
  { a = document.getElementById(a);

   var i = parseInt(a.style.width)+xincr ;
   var j = parseInt(a.style.height)+yincr;

   if(i <= iWidth)
   {a.style.width = i+"px";}
   else
   {a.style.width = iWidth+"px";}

   if(j <= iHeight)
   {a.style.height = j+"px";}
   else
   {a.style.height = iHeight+"px";}

   if(!((i > iWidth) && (j > iHeight)))
   setTimeout( "ToolTip.animate('"+a.id+"',"+iHeight+","+iWidth+")",1);
    }

   Init(id);
}
function show_search(val) {
	if (val=="adv") {
	var x1="bsc_search";
	var x2="adv_search";
	}else{
	var x2="bsc_search";
	var x1="adv_search";
	}
	document.getElementById(x1).style.display="none";
	document.getElementById(x2).style.display="";
}
