var waitInterval;

//Cross Browser Object Retrieval
function getObjectByID(objectID){
	if (document.all!=null){
		return document.all[objectID];
	} else if (document.getElementById){
		return document.getElementById(objectID);
	}
}

function moveDiv(moveUp) {	
	if(moveUp) {
		waitInterval=window.setInterval("moveDivUp()",20);
		SetCookie("CustomerStatus","ExistingCustomer","30");
		
		
	} else { 
		waitInterval=window.setInterval("moveDivDown()",20);
		SetCookie("CustomerStatus","NewCustomer","30");
	}
	
}
//
//Check Customer Status while Page Loading and Display Respective Dynamic View accordingly
//
function CheckCustomerStatus()
{
    var custStatus=getCookie("CustomerStatus");
    if(custStatus=='ExistingCustomer')
        waitInterval=window.setInterval("moveDivUpOnLoad()",0);
}

//
//Set Customer Status in Cookie
//
function SetCookie(cookieName,cookieValue,nDays) 
{
    var today = new Date();
    var expire = new Date();
    if (nDays==null || nDays==0) nDays=1;
    expire.setTime(today.getTime() + 3600000*24*nDays);
    document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

//
//Get Customer Status from Cookie
//
function getCookie(NameOfCookie)
{
    if (document.cookie.length > 0) 
    { 
        begin = document.cookie.indexOf(NameOfCookie+"="); 
        if (begin != -1)
        { 
            begin += NameOfCookie.length+1; 
            end = document.cookie.indexOf(";", begin);
        if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end)); } 
    }
    return null; 
}


function moveDivUp() {
	var motionDiv=getObjectByID("motiongallery");
	var divTop=parseInt(motionDiv.style.top);
	if (divTop <=-275) {
		window.clearInterval(waitInterval) 
	} else {	
		divTop-=8;
		motionDiv.style.top=divTop+"px";
	}
	
}

function moveDivDown() {
	var motionDiv=getObjectByID("motiongallery");
	var divTop=parseInt(motionDiv.style.top);
	if (divTop >=0) {
		window.clearInterval(waitInterval) 
	} else {	
		divTop+=8;
		motionDiv.style.top=divTop+"px";
	}
	
}

function moveDivUpOnLoad() {
	var motionDiv=getObjectByID("motiongallery");
	var divTop=parseInt(motionDiv.style.top);
	if (divTop <=-275) {
		window.clearInterval(waitInterval) 
	} else {	
		divTop-=279;
		motionDiv.style.top=divTop+"px";
	}
	
}

