function addressPopUp(sclrfnum){
	var url = "../tiles/components/checkout/billingShippingAddress.jsp?multiAddress=Y&cartId="+sclrfnum;
	window.open( url,'multiAddr','left=300,top=100,width=380,height=380');
}
function divShowHide(divName,act)
{
	if (act == "showit")
	{document.getElementById(divName).style.display = 'block';
			if(navigator.appName == "Microsoft Internet Explorer")
			{
				var divNode = document.getElementById(divName);
				divNode.insertAdjacentHTML("afterEnd", '<IFRAME frameBorder="10" scrolling="no" id="_hvrShm" name="_hvrShm" style="position:relative; z-index:5; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0); " />'); 
				var iframeShm = document.getElementById("_hvrShm");
				iframeShm.style.top = divNode.offsetTop; 
				iframeShm.style.left = divNode.offsetLeft; 
				iframeShm.style.width = divNode.offsetWidth; 
				iframeShm.style.height = divNode.offsetHeight;
			}
	}
	else if (act == "hideit")
	{
			
			document.getElementById(divName).style.display = 'none';
			if(document.getElementById('_hvrShm')!=null)
				while((el=document.getElementsByName('_hvrShm')).length!=0){el[0].parentNode.removeChild(el[0]);}
	}
}

function divShowitHideit(divId,act){
	if($(divId)!= null){
		$(divId).style.display = 'none';
		if (act == "show")
		{
			$(divId).style.display = 'block';
		}
		else if (act == "hide")
		{
			$(divId).style.display = 'none';
		}
	}
}
function toggleDiv(divId,mainDiv,isLastCategory){	
		$(divId).style.display = ($(divId).style.display == 'none'?'block':'none');
		if(isLastCategory == 'Y'){
			if($(divId).style.display == 'none'){
				$(mainDiv).className = "lastLink";
			}
			else{
				$(mainDiv).className = "normalLink";
			}
		}
}
function footerBottom() {
    //alert("Hi..");
	var _height=document.body.scrollHeight;
	var _width=document.body.scrollWidth;
	var height = parseInt(_height);
	var width = parseInt(_width);
	//alert("Height --->> "+height);
	//alert("Width --->> "+width);
	//alert("Your resolution is "+screen.width+"x"+screen.height);
	
	var footer=document.getElementById('footer');
	var _bodyCont= document.getElementById('bodyContentDiv').offsetHeight;
	var bodyCont= parseInt(_bodyCont);
	//here actual header hiehgt + footer hieght =311   86+143=229
	
	//alert(bodyCont);	

	if (screen.height == 1024 && bodyCont < 591 && footer!= null)
	{
		//alert("1024 and 621");
		footer.style.position='relative';
		footer.style.bottom='0px';
	}
	else if (screen.height == 960 && bodyCont < 510 && footer!= null)
	{
		//alert("960 and 559");
		footer.style.position='relative';
		footer.style.bottom='0px';
	}
	else if (screen.height == 800 && bodyCont < 347 && footer!= null)
	{
		//alert("800 and 399");
		footer.style.position='relative';
		footer.style.bottom='0px';
	}
	else if (screen.height == 768 && bodyCont < 315 && footer!= null)
	{
		//alert("720 and 319");
		footer.style.position='relative';
		footer.style.bottom='0px';
	}
	else if (screen.height == 720 && bodyCont < 267 && footer!= null)
	{
		//alert("864 and 443");
		footer.style.position='relative';
		footer.style.bottom='0px';
	}
	else if (screen.height == 864 && bodyCont < 411 && footer!= null)
	{
		//alert("768 and 289");
		footer.style.position='relative';
		footer.style.bottom='0px';
	}
	else if (screen.height == 612 && bodyCont < 155 && footer!= null)
	{
		//alert("612 and 191");
		footer.style.position='relative';
		footer.style.bottom='0px';
	}
	else if (footer!= null){
		//alert("Inside else.........");
		footer.style.position='';
		footer.style.bottom='';
		
	}
}
window.onresize = function(){
	//alert('raka...');
	var footer=document.getElementById('footer');
	if(footer!=null){
		footer.style.position='';
		footer.style.bottom='';
	}
}
function checkLoginIdPwd(formId){
	var logId = document.forms[formId].elements['loginId'];
	var pwd = document.forms[formId].elements['password'];
	if(logId.value==''){
		alert('Please enter User Id.');
		logId.focus();
		return false;
	}else{
		if(!checkEmail(logId.value)){
			alert('Please enter Valid User Id.');
			return false;
		}
	}
	if(pwd.value==''){
		alert('Please enter Password.');
		pwd.focus();
		return false;
	}else{
		if(!validatePassword(pwd.value)){
			alert('Please enter Valid Password.');
			pwd.focus();
			return false;
		}
	}
	return true;
}
function getLoginForm(pageUrl){
	try{
		var myAjax = new Ajax.Updater('login',pageUrl ,{onSuccess:showLoginForm});
	}catch(err){alert(err.message);}
}
function showLoginForm(transport){
	try{
		divShowHide('login','showit');
	}catch(err){alert(err.message);}
	
}
function isValidForm(){
	if($('loginId').value == ''){
		alert('Please enter loginId.');
		$('loginId').focus();
		return false;
	}
	else if($('password').value == ''){
		alert('Please enter password.');
		$('password').focus();
		return false;
	}else{return true};

}
function loginSubmit(){
	if(isValidForm()){
	$('loginForm').request({
	  onComplete: function(transport){ $('login').innerHTML = transport.responseText ;},
	  onFailure:function(){alert('Oops Error.');}
	  //onSuccess: updateShoppingCart
	});
	}
}
function updateShoppingCart(){
	
	var updatableDiv = null;
	var url = null;
	
	if($('shoppingCartItemsDiv') != null){
		updatableDiv = 'shoppingCartItemsDiv';
		url = "../faces/tiles/components/checkout/shoppingCartItemsComponent.jsp";
	}
	if($('minishoppingcart')!= null){
		updatableDiv = 'minishoppingcart';
		url = "../faces/tiles/components/product/miniShoppingCart.jsp";
	}
	if(updatableDiv != null)
	{
		try{ 
		var params = {'invoke:action':'ShoppingCartActionBean.shoppingCartItemsComponent_init'};
		var myAjax = new Ajax.Updater(updatableDiv, 
						url, 
						{
							method: 'GET', 
							parameters: params,
							onFailure:handleFail
						});
		}catch(err){alert(err.message);}
	}
}
function handleFail(){
	alert('Oops!! Error.');
}
function hideLoginForm (pageUrl,loginId,quanty){
	try{
		if((loginId != null && loginId != 'undefined' && loginId != 'null' ) && loginId.length > 1){
			$('sign_in_out').innerHTML = '<a href="../faces/jsp/shoppingCart.jsp" title="Shopping Cart">Shopping Cart('+quanty+')</a>  | <a href="'+pageUrl+'">Sign Out</a>';
			if($('_isLogged') != null && $('_isLogged').innerHTML == 'false')
				$('_isLogged').innerHTML="true";	
			updateShoppingCart();
		}
	}catch(err){alert(err.message);}
	divShowHide('login','hideit');
}
Ajax.Responders.register({
  onCreate: showProcessing,
  onComplete: hideProcessing
});

function showProcessing() {
  if(Ajax.activeRequestCount > 0)
    $('loading').style.display = 'block';
}

function hideProcessing () {
  if(Ajax.activeRequestCount <= 0)
    $('loading').style.display = 'none'; 
}
Ajax.Responders.register({
  onCreate: showProcessing,
  onComplete: hideProcessing
});
