var mainDivId;
var mainDivHideTime=1000;
/**
* @function		: getPageSize
* @created By	: Shahvez Alam
* @created On	: 23-jan -2009
* @description	: This function is used to get the page size.
* @params		: 
* @returns      : arrayPageScroll(Array)
*/	
function getPageSize(){
       
        var xScroll, yScroll;
       
        if (window.innerHeight && window.scrollMaxY) { 
                xScroll = document.body.scrollWidth;
                yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
                xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
                xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
        }
       
        var windowWidth, windowHeight;
        if (self.innerHeight) { // all except Explorer
                windowWidth = self.innerWidth;
                windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowWidth = document.documentElement.clientWidth;
                windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
        }       
       
        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
                pageHeight = windowHeight;
        } else {
                pageHeight = yScroll;
        }

        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){     
                pageWidth = windowWidth;
        } else {
                pageWidth = xScroll;
        }


        arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
        return arrayPageSize;
}

/**
* @function		: getPageScroll
* @created By	: Shahvez Alam
* @created On	: 23-jan -2009
* @description	: This function is used to get the scroll page size.
* @params		: 
* @returns      : arrayPageScroll(Array)
*/	

function getPageScroll(){

        var yScroll;

        if (self.pageYOffset) {
                yScroll = self.pageYOffset;
        } else if (document.documentElement && document.documentElement.scrollTop){      // Explorer 6 Strict
                yScroll = document.documentElement.scrollTop;
        } else if (document.body) {// all other Explorers
                yScroll = document.body.scrollTop;
        }

        arrayPageScroll = new Array('',yScroll)
        return arrayPageScroll;
}

/**
* @function		: getWidth
* @created By	: Shahvez Alam
* @created On	: 23-jan -2009
* @description	: This function is used to get the page width.
* @params		: 
* @returns      : myWidth(Float)
*/	
function getWidth(){
var myWidth;
var myHeight;

	if( typeof( window.innerWidth ) == 'number' ) { 
	
	//Non-IE 
	
	myWidth = window.innerWidth;
	myHeight = window.innerHeight; 
	
	} else if( document.documentElement && 
	
	( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { 
	
	//IE 6+ in 'standards compliant mode' 
	
	myWidth = document.documentElement.clientWidth; 
	myHeight = document.documentElement.clientHeight; 
	
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { 
	
	//IE 4 compatible 
	
	myWidth = document.body.clientWidth; 
	myHeight = document.body.clientHeight; 
	
	} 
	
	return myWidth;
}

/**
* @function		: hide_dropdowns
* @created By	: Shahvez Alam
* @created On	: 23-jan -2009
* @description	: This function is used to hide/show the drop downs on the page based on the passed value.
* @params		: what(String)
* @returns      : 
*/	

function hide_dropdowns(what){
if(what=="in"){
var anchors = document.getElementsByTagName("select");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
anchor.style.visibility='hidden';
}
}else{
var anchors = document.getElementsByTagName("select");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
anchor.style.visibility='visible';
}
}
}

/**
* @function		: openDiv
* @created By	: Shahvez Alam
* @created On	: 23-jan -2009
* @description	: This function is used to open the mask div and form div.
* @params		: divId(String)
* @returns      : 
*/	

function openDiv(divId)
{
	mainDivId=divId;
	$(divId).style.height='100%';
	$(divId).style.visibility='visible';
	new Effect.Appear(divId+'FormDiv');
	new Effect.BlindDown(divId+'FormDiv');
	hide_dropdowns('in');
	scrollEvent();
}

/**
* @function		: closeDiv
* @created By	: Shahvez Alam
* @created On	: 23-jan -2009
* @description	: This function is used to close the mask div and form div.
* @params		: divId(String)
* @returns      : 
*/	

function closeDiv(divId)
{
	new Effect.BlindUp(divId+'FormDiv');
	new Effect.Fade(divId+'FormDiv');
	setTimeout("hideMainDiv('"+divId+"')",mainDivHideTime);	
}

/**
* @function		: hideMainDiv
* @created By	: Shahvez Alam
* @created On	: 23-jan -2009
* @description	: This function is used to close the mask div after set time interval.
* @params		: divId(String)
* @returns      : 
*/	

function hideMainDiv(divId){
$(divId).style.visibility='hidden';
hide_dropdowns('out');	
}

/**
* @function		: scrollEvent
* @created By	: Shahvez Alam
* @created On	: 23-jan -2009
* @description	: This function is used to position the both the div, to keep pop up always in center.
* @params		: divId(String)
* @returns      : 
*/

function scrollEvent() {
   var arrayPageSize = getPageSize();
   var arrayPageScroll = getPageScroll();
   if($(mainDivId)){
   $(mainDivId).style.top=arrayPageScroll[1]+'px';	
   $(mainDivId+'FormDiv').style.left=(arrayPageSize[2]*.5-125)+'px';
   $(mainDivId+'FormDiv').style.top=arrayPageScroll[1] + (arrayPageSize[3]/5)+'px';
   }
   if($('ShopOnlineInfoBox')){
		if(navigator.appVersion.indexOf(' MSIE 6.0')!=-1){
		positionBox('ShopOnlineInfoBox')
		}
	}
}

function positionBox(divId){
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	$(divId).style.width=((arrayPageSize[2]-25))+'px';
	if(navigator.appVersion.indexOf(' MSIE 7.0')!=-1){
		$(divId).style.width=((arrayPageSize[2]-9))+'px';	
	}
	if(navigator.appVersion.indexOf(' MSIE 6.0')!=-1){
		$('ShopOnlineInfoBox').style.position='absolute';
		$(divId).style.width=((arrayPageSize[2]-10))+'px';
	}
	$(divId).style.left=3+'px';
	$(divId).style.top=arrayPageScroll[1] + (arrayPageSize[3]-51)+'px';
	if(navigator.appVersion.indexOf(' MSIE 6.0')!=-1){
		$(divId).style.top=arrayPageScroll[1] + (arrayPageSize[3]-53)+'px';
	}
} 

window.onscroll = scrollEvent;

