﻿function DisableAfterClick( target, disabledText )
{
    //var target = document.getElementById( targetId );
    if( !target )
    {
        return;
    }
    
    var clone=null;

    try
    {
        clone = target.cloneNode();
    }
    catch(x)
    {   
        try
        {
            clone = target.cloneNode(true);
        }
        catch(y)
        {
            clone=null;
        }
    }
    if( clone )
    {
        target.style.display='none';
        if( disabledText )
        {
            clone.value = disabledText;
        }
        clone.disabled=true;
        
        if(typeof target.insertAdjacentElement!='undefined')
        {
            target.insertAdjacentElement('beforeBegin',clone);
        }
        else
        {   
            target.parentNode.insertBefore(clone,target);
        }
    }
}

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 setCookie(NameOfCookie, value, expiredays) 
{ var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
document.cookie = NameOfCookie + "=" + escape(value) + 
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie) 
{ if (getCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

}

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.scrollHeight;
	} 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 getScreenCenterY() {
    var y = 0;

    y = getScrollOffset() + (getInnerHeight() / 2);

    return (y);
}

function getScreenCenterX() {
    return (document.body.clientWidth / 2);
}

function getInnerHeight() {
    var y;
    if (self.innerHeight) // non IE
    {
        y = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) {
        y = document.documentElement.clientHeight; // IE6
    }
    else if (document.body) // IE
    {
        y = document.body.clientHeight;
    }
    return (y);
}

function getScrollOffset() {
    var y;
    if (self.pageYOffset) // non IE
    {
        y = self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop) {
        y = document.documentElement.scrollTop; // IE6
    }
    else if (document.body) // IE
    {
        y = document.body.scrollTop;
    }
    return (y);
}

function openLookBook() {

    window.open("/lookbook/index.html", "lookbook", "location=0,status=0,width=1024,height=768");
}
