loadimges = "/images/home/menu_homeh.jpg,/images/home/menu_goalsh.jpg,/images/home/menu_calendarh.jpg,/images/home/menu_wishlisth.jpg,/images/home/menu_activityh.jpg,/images/home/menu_friendsh.jpg,/images/home/menu_searchh.jpg,/images/home/menu_groupsh.jpg,/images/home/menu_mediah.jpg".split(",");
var tempImg = [];

for(var x=0;x<loadimges.length;x++) {
    tempImg[x] = new Image();
    tempImg[x].src = loadimges[x];
}

function PrecacheImages(loadimges)
{
	var tempImg = [];
	for(var x=0;x<loadimges.length;x++)
	{
    	tempImg[x] = new Image();
	    tempImg[x].src = loadimges[x];
	}
}


function make_blank()
{
   var Lid = document.Login_main.ID.value;
   if(Lid=="Screen name or email" )
        document.Login_main.ID.value ="";
}

function fill_email()
{
   var Lid = document.Login_main.ID.value;
   if(Lid=="" || Lid == null )
        document.Login_main.ID.value ="Screen name or email";
}
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{

    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "" : "none";

    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.display = iState ? "" : "none";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.display = iState ? "" : "none";

    }
}

function make_blank_pass()
{

  toggleBox('divPasswordText',0);
  toggleBox('divPasswordPassword',1);
  document.Login_main.Password.focus();
}

function fill_pass()
{

  var pword = document.Login_main.Password.value;
  if(pword=="" || pword==null)
  {
    toggleBox('divPasswordPassword',0);
    toggleBox('divPasswordText',1);
  }
}


function openItemDetail(ASIN)
{
	window.open('wishitemdetails.php?&ASIN='+ASIN, 'detailwin','width=1000,height=600,resizable=yes,scrollbars=1');
	return;
}

function openItemDetail_W(WID,ASIN)
{
	window.open('wishitemdetails.php?WID='+WID+'&ASIN='+ASIN, 'detailwin','width=1000,height=600,resizable=yes,toolbar=1,scrollbars=1');
	return;
}

function ActionAdditem(Location)
{
   document.location.href=Location;
}
function hilight(Name,ImgName,extension)
{
	IMGurl = '/images/home/'+ ImgName +'.jpg';

	if(extension != undefined)
	{

		if(extension.length>0)
		{
			IMGurl = '/images/home/'+ ImgName +'.'+extension;
		}
	}
	$(Name).setStyle({'background':'url('+ IMGurl+')'});
}
function hilightehover(H_ele,type)
{
	if(type==1)
	{
		$(H_ele).style.backgroundPosition = 'center bottom';
	}else
	{
		$(H_ele).style.backgroundPosition = 'center top';
	}
}

function popupaddfriendwindow(friendid)
{
  window.open("list_pop.php?action=friend&ID=" + friendid,"friendwin","width=500,height=250");
  return;
}

function spliter(b,maxl)
{
	var i=0;
	var value="";
	var astr = new Array();

	astr = b.split(" ");

	while (astr[i]!= null )
	{
	    if((astr[i].length) > maxl)
	    {
	        var temp="";
	        var j=0;
	        var k =0;
	        var len = 0;
	        var loop = 0;
	        len = astr[i].length;
	        loop = parseInt(len/maxl);
	        while (j <= loop)
	        {
	            temp = temp + astr[i].substr(k,maxl);
	            if(j != loop)
	                temp = temp + " ";
	            k = k + maxl;
	            j = j +1;
	        }
	        //temp = temp.rtrim();
	        astr[i] = temp;
	    }
	    i=i+1;
	}

	value = astr.join(" ");
	return value;
}
function IsCookieEnable()
{
	var cookieEnabled = (navigator.cookieEnabled) ? true : false;

	//if not IE4+ nor NS6+
	if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled)
	{
		document.cookie="testcookie";
		cookieEnabled = (document.cookie.indexOf("testcookie")!=-1) ? true : false;
	}

	//if cookies are enabled on client's browser
	if (!cookieEnabled)
	{
		document.location.href='enable_cookie.php';
	}

}


function SetPopupBackground(IsPadd)
{

	if($("bluediv")!= null)
	{

	var Paddhor = 10;
	var Paddver = 76;

	if(IsPadd=='NoPadd')
	{
		Paddhor = 0;
		Paddver = 15;
	}

	 var rightpos = '-'+($('bodyid').offsetLeft+Paddhor) + 'px';
//	 var tmph = ($('bodyid').getHeight()+Paddver) + 'px';
	 var tmph = $('bodyid').getHeight() + 'px';

		 if (parseInt(navigator.appVersion)>3)
		 {
			 if (navigator.appName=="Netscape") {
			  var tmpw = window.innerWidth + 'px';
			 }
			 if (navigator.appName.indexOf("Microsoft")!=-1) {
			  var tmpw = document.body.offsetWidth + 'px';
			 }
		 }
		 $("bluediv").setStyle({display: 'block', width: tmpw , height: tmph , position:'absolute', top: '0px' ,right :rightpos ,opacity : '0.6',margin:'0px'} );
	}
}


function SetGoalpopupPos()
{
	var YellowWidht =  $('DefaultGoalDiv').getWidth();
	var bodywidth = $('bodyid').getWidth();
	leftOfset =  (bodywidth/2)-(YellowWidht/2);
	leftOfset = leftOfset + 'px';
	$("DefaultGoalDiv").setStyle({left:leftOfset});
}

function CancelFriendNotify()
{
	new Ajax.Request('inc/calendarhandler.php', {
		method: 'post',
		parameters: {HideFriendNotify:true},
		asynchronous: false,
		onSuccess: function (){},
		onFailure: function (){}
		});
}

function Fix_PNGBEHAVIOR()
{
	try {
        var arVersion = navigator.appVersion.split("MSIE");
        var version = parseFloat(arVersion[1]);
        if ((version >= 5.5) && (version < 7) && (document.body.filters))
        {
			DD_belatedPNG.fix('.png_bg');
        }
    } catch(e) {}
}

function ResizeiFrames()
{
	if(parent.frames.length != 0){
		 if(typeof(ResizeFrame)=='function'){
			 ResizeFrame();
		 }
	}
}

Ajax.Responders.register({
    onCreate: function() {
     var count = Ajax.activeRequestCount++;
//     alert('start' + count);
   },
   onComplete: function() {
     var count =  Ajax.activeRequestCount--;
//     alert('complete' + count);
     ResizeiFrames();
   }
});

function make_i_blank(id,text)
{
   var Lid = $(id).value;
   if(Lid == text )
	   $(id).value ="";
}

function fill_input(id,text)
{
   $(id).value = trim($(id).value);
   var Lid = $(id).value;
   if(Lid=="" || Lid == null )
        $(id).value = text;
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function trimiput(id)
{
	$(id).value = trim($(id).value);
}