/* New Code for Rollover ----------------------------------------------------- */

function escapeEx(text){
    return encodeURIComponent(text);
}


// JavaScript Document
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};




var g_arrImgObjs = new Array();
function initImages(arrImgSource){
	for(i = 0 ; i < arrImgSource.length ; i+=3){
		g_arrImgObjs.push(arrImgSource[i]);
		picOff = new Image();
	   	picOff.src=arrImgSource[i+1];
		g_arrImgObjs.push(picOff);
		picOn = new Image();
	   	picOn.src=arrImgSource[i+2];
		g_arrImgObjs.push(picOn);
	}
}

function lightupImg(imgName){
	for(i = 0 ; i < g_arrImgObjs.length ; i+=3){
		if(g_arrImgObjs[i] == imgName){
			document.getElementById(imgName).src = g_arrImgObjs[i+2].src;
			if(imgName == "myfashionfile") {
				document.getElementById('userImg').style.border = "1px solid #ee1166";
			}
			break;
		}
	}
}

function turnoffImg(imgName){
	for(i = 0 ; i < g_arrImgObjs.length ; i+=3){
		if(g_arrImgObjs[i] == imgName){
			document.getElementById(imgName).src = g_arrImgObjs[i+1].src;
			if(imgName == "myfashionfile") {
				document.getElementById('userImg').style.border = "1px solid #ffffff";
			}
			break;
		}
	}
}

function myParseInt(strDecNum){
    if(strDecNum.length<=0 || strDecNum=="")
        return 0;
    
    intStr = "0123456789";
    
    for(i = 0 ; i < strDecNum.length; i++){
       if(intStr.indexOf(strDecNum.substring(i,1))<0)
            return 0;
    }
    return parseInt(strDecNum);
}

 function findAbsPosX(obj) { 
        var curleft = 0; 
        if(obj.offsetParent) {
            while(1) { 
                curleft += obj.offsetLeft; 
                //curleft += obj.scrollLeft; 
                if(!obj.offsetParent) 
                    break; 
                obj = obj.offsetParent;  
            } 
        }
        else 
            if(obj.x) 
                curleft += obj.x; 
        //alert(curleft);
		return curleft;
	}

    function findAbsPosY(obj) { 
        var curtop = 0; 
        if(obj.offsetParent) 
            while(1) { 
                curtop += obj.offsetTop; 
                //curtop -= obj.scrollTop; 
                if(!obj.offsetParent) 
                    break; 
                obj = obj.offsetParent; 
            } 
        else 
            if(obj.y) 
                curtop += obj.y; 
        //alert(curtop);
		return curtop;
    }
    
                        
    //Get Client Height ======================================================================== */
    function GetClientWidth(){
        var viewportwidth;

        // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

        if (typeof window.innerWidth != 'undefined'){
           viewportwidth = window.innerWidth;
        }

        // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

        else if (typeof document.documentElement != 'undefined'
         && typeof document.documentElement.clientWidth !=
         'undefined' && document.documentElement.clientWidth != 0) {
            viewportwidth = document.documentElement.clientWidth;
        }

        // older versions of IE

        else{
           viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
        }

        return viewportwidth;
    }//end method
    
	
    //Get Client Width ========================================================================= */
	function GetClientHeight(){
        var viewportheight;

        // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

        if (typeof window.innerWidth != 'undefined'){
           viewportheight = window.innerHeight;
        }
        // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
        else if (typeof document.documentElement != 'undefined'
         && typeof document.documentElement.clientWidth !=
         'undefined' && document.documentElement.clientWidth != 0){
            viewportheight = document.documentElement.clientHeight;
        }

        // older versions of IE

        else{
           viewportheight = document.getElementsByTagName('body')[0].clientHeight;
        }
        
        return viewportheight;
    }//end method



	function getMouseXPos(e) {
	
		if (document.all) { //IE4 and up
			return (event.clientX + document.body.scrollLeft);
		} else if (document.layers) {
			if(!e)
				e = window.event;
			return e.pageX
		} else if (document.getElementById) {
			if(!e)
				e = window.Event;
			return (e.clientX + document.body.scrollLeft);
		} 
	
	}
	// <B style="color:black;background-color:#A0FFFF">Get</B> the vartical <B style="color:black;background-color:#ff9999">position</B> of the mouse
	function getMouseYPos(e) {
		if (document.all) { //IE4 and up
			return (event.clientY + document.body.scrollTop);
		} else if (document.layers) {
			if(!e)
				e = window.event;
			return e.pageY;
		} else if (document.getElementById) { // mozilla
			if(!e)
				e = window.Event;
			return (e.clientY + document.body.scrollTop);
		} 
	
	}


function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}


function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}


    function centerDivAbs(elID,wD,hD){
		var clW =  GetClientWidth();
        var clH =  GetClientHeight();

        elLeft = f_scrollLeft() + Math.round((clW - wD)/2);
        if(elLeft < 0)
            elLeft = 0;

        elTop = f_scrollTop() + Math.round((clH - hD)/2);
        if(elTop < 0)
            elTop = 0;

        document.getElementById(elID).style.left =  elLeft + 'px';
        document.getElementById(elID).style.top =  elTop + 'px';

    }


// Get the height of the entire document
// --------------------------------------------------------------------
function getPageWidth()
{
    return (document.body.scrollWidth)?document.body.scrollWidth:document.width;
} 

function getPageHeight()
{
    return (document.body.scrollHeight)?document.body.scrollHeight:document.height;
}
    
	
	function topMenuNavPositioning(stretch) {
		//var clientWidth = GetClientWidth();	
		var clientWidth = f_clientWidth();
		var topNavMenuWidth = 950;
		var absOffsetLeft = (clientWidth - topNavMenuWidth) / 2;
		
		
		var absOffsetY = 57;
		
		document.getElementById('wrapper').style.paddingTop = "100px";
		
		if(clientWidth < (g_pageMinWidth + 24)) { 
			absOffsetLeft = 37;
		}
	    if(document.getElementById('maintop')) {
			divMenuMainTop = document.getElementById('maintop');
			divMenuMainTop.style.left = absOffsetLeft - 25 + 'px';  
			divMenuMainTop.style.top = 0 + 'px'; 
			divMenuMainTop.style.display = '';
		}
	}
	
	//Top Menu Nav Positioning : start =========================================================== */
	function topMenuNavPositioning_old(stretch) {
		
		//var clientWidth = GetClientWidth();	
		var clientWidth = f_clientWidth();
		var topNavMenuWidth = 950;
		var absOffsetLeft = (clientWidth - topNavMenuWidth) / 2;
		
		
		var absOffsetY = 57;
		
		document.getElementById('wrapper').style.paddingTop = "100px";
		
		if(clientWidth < (g_pageMinWidth + 24)) { 
			absOffsetLeft = 37;
		}
	    
		
		/* New Menu Positioning : start =========================================================== */
		divMenuE_1 = document.getElementById('fashionairLogo');
		divMenuE_1.style.left = absOffsetLeft + 350 + 'px';  
		divMenuE_1.style.top = absOffsetY  - 34 + 'px';  
		divMenuE_1.style.display = '';
		
		divMenuE_2 = document.getElementById('menuNavTab1');
		divMenuE_2.style.left = absOffsetLeft + 330 + 'px';  
		divMenuE_2.style.top = absOffsetY + 5 + 'px';  
		divMenuE_2.style.display = '';
		
		divMenuE_3 = document.getElementById('menuNavTab2');
		divMenuE_3.style.left = absOffsetLeft + 414 + 'px';  
		divMenuE_3.style.top = absOffsetY + 5 + 'px';  
		divMenuE_3.style.display = '';
		
		divMenuE_4 = document.getElementById('menuNavTab3');
		divMenuE_4.style.left = absOffsetLeft + 487 + 'px';  
		divMenuE_4.style.top = absOffsetY + 5 + 'px';  
		divMenuE_4.style.display = '';
		
		divMenuE_5 = document.getElementById('menuNavTab4');
		divMenuE_5.style.left = absOffsetLeft + 576 + 'px';  
		divMenuE_5.style.top = absOffsetY + 5 + 'px';  
		divMenuE_5.style.display = '';
		
		divMenuE_6 = document.getElementById('submenuNavTab_1');
		divMenuE_6.style.left = absOffsetLeft + 330 + 'px';  
		divMenuE_6.style.top  = absOffsetY  +  43 + 'px';  
		divMenuE_6.style.display = '';
		
		divMenuE_7 = document.getElementById('submenuNavTab_2');
		divMenuE_7.style.left = absOffsetLeft + 330 + 'px';  
		divMenuE_7.style.top  = absOffsetY  +  43 + 'px';  
		divMenuE_7.style.display = '';
		
		divMenuE_8 = document.getElementById('submenuNavTab_3');
		divMenuE_8.style.left = absOffsetLeft + 330 + 'px';  
		divMenuE_8.style.top  = absOffsetY  +  43 + 'px';  
		divMenuE_8.style.display = '';
        
		divMenuE_9 = document.getElementById('UserAccountStatus');
		if(stretch) {
			if(clientWidth < g_pageMinWidth) { 
			   divMenuE_9.style.left = absOffsetLeft + 810 + (g_pageMinWidth - 1000) + 'px'; 
			}else {
				divMenuE_9.style.left = clientWidth - 257 + 'px'; 
/*
    			if (navigator.appName.indexOf("Microsoft") != -1) {
	    		   divMenuE_9.style.left = clientWidth - 255 + 'px'; 
	    		}
	    		else{
	    		    divMenuE_9.style.left = clientWidth - 270 + 'px'; 
	    		}
*/	    		
			}
		}else {
			if(clientWidth < g_pageMinWidth) { 
			   divMenuE_9.style.left = absOffsetLeft + 718 + 'px';
			}else {
			   divMenuE_9.style.left = absOffsetLeft + 730 + 'px';
			}
		}
		
		divMenuE_9.style.top  = absOffsetY  +  13 + 'px';  
		divMenuE_9.style.display = '';
		
	    divMenuE_mffOn = document.getElementById('MyFashionFilePicture');
		if(stretch) {
			divMenuE_mffOn.style.left = 12 + 'px';
		}else {
		    divMenuE_mffOn.style.left = absOffsetLeft - 25 + 'px';
		}
		divMenuE_mffOn.style.top  = absOffsetY  -  45 + 'px';  
		divMenuE_mffOn.style.display = '';
		
		divMenuE_11 = document.getElementById('topNavMenuGradient');
		divMenuE_11.style.left = absOffsetLeft + 'px';  
		divMenuE_11.style.top  = absOffsetY - 57 + 'px';  
		divMenuE_11.style.display = '';
		
		divMenuE_12 = document.getElementById('topNavBetaGradient');
		divMenuE_12.style.left = absOffsetLeft + 685 + 'px';  
		divMenuE_12.style.top  = absOffsetY - 57 + 'px';  
		divMenuE_12.style.display = '';
		
		divMenuE_13 = document.getElementById('topNavBetaComment');
		divMenuE_13.style.left = absOffsetLeft + 770 + 'px';  
		divMenuE_13.style.top  = absOffsetY - 50 + 'px'; 
		divMenuE_13.style.display = '';
		/* New Menu Positioning : end ============================================================ */ 
		
		
		
    }
    //Top Menu Nav Positioning : end ================================================================ */


/* Pink Box : start ================================================================================= */
function pinkBoxPositioning(obj,pinkBoxTopPos) {
	
	divMenuE1 = document.getElementById(obj);
	
	if(divMenuE1 == null){
	    return;
	}

	var browserVersion = navigator.appVersion;
	
	absOffsetX = findAbsPosX(divMenuE1);
	absOffsetY = findAbsPosY(divMenuE1);
	
	BrowserDetect.init();
	if(BrowserDetect.browser == 'Firefox' || BrowserDetect.browser == 'Safari' && BrowserDetect.OS == 'Windows') {
		var extrapix = 5;
	}else if(BrowserDetect.browser == 'Safari' && BrowserDetect.OS == 'Mac') {
		var extrapix = 5;
	}else if(BrowserDetect.browser == 'Explorer' && BrowserDetect.OS == 'Windows') {
		if(browserVersion.indexOf("MSIE 6.0") != -1) {
		   var extrapix = -4;
	    }else {
	       var extrapix = 0;
		}
	}else {
		var extrapix = 0;
	}
	
	divMenuE1.style.left = /*absOffsetX*/ + 820 + 'px';
	divMenuE1.style.top = /*absOffsetY */ + pinkBoxTopPos +extrapix+'px';
	
	divMenuE1.style.display = '';
}
/* Pink Box : end =================================================================================== */


/* Style Diary Imgage: start ======================================================================== */
function styleDiaryImgagePos(obj) {
	
	if(obj == "stylediaryimgage") {
		divMenuE1 = document.getElementById(obj);
		
		absOffsetX = findAbsPosX(divMenuE1);
		absOffsetY = findAbsPosY(divMenuE1);
		
		divMenuE1.style.left = /*absOffsetX +*/ 'px';
		divMenuE1.style.top = /*absOffsetY*/  + 33 + 'px';
		divMenuE1.style.display = '';
	}
}

//Page Fixed Positioning() {
function pageHeaderFixedPositioning() {
	var clientWidth = GetClientWidth(); 
	
	if (clientWidth >= g_pageMinWidth) {
		document.getElementById('wrapper').style.width = "100%";
		document.getElementById('mainAreaContent').style.width = "100%";
	}else { 
		document.getElementById('wrapper').style.width = g_pageMinWidth + "px";
		document.getElementById('mainAreaContent').style.width = (g_pageMinWidth + 100) + "px";
	}

}

function pageContentFixedPositioning() {
    var clientWidth = GetClientWidth(); 
	
   var pageLeftMargin = (clientWidth - g_pageMinWidth) / 2;
   if(pageLeftMargin < 0)
        pageLeftMargin = 0;
        
   if(document.getElementById("mainshpop")) {
        document.getElementById("mainshpop").style.marginLeft = pageLeftMargin + "px";
   }
}


function pageFooterFixedPositioning() {
	var clientWidth = GetClientWidth(); 
    var pageLeftMargin = (clientWidth - g_pageMinWidth) / 2;
    if(pageLeftMargin < 0)
        pageLeftMargin = 0;
    if(document.getElementById("footer"))
        document.getElementById("footer").style.paddingLeft = pageLeftMargin + "px";
}

/* Position Shop Page in the center : end ================================================ */

//Page Stretch Positioning ======================================================================== */
function pageHeaderStretchPositioning() {
	var currentResizedwidth;
	currentResizedwidth = GetClientWidth();

	if (currentResizedwidth >= (g_pageMinWidth)) {
        if(g_overflowHidden){
/*        
			if (navigator.appName.indexOf("Microsoft") != -1) {
	           document.getElementById('body').style.overflow = "hidden";
	           document.body.scroll = "no";
	        }else {
	            document.getElementById('body').style.overflow = "visible";
	            document.body.scroll = "yes";
	        } 
*/	        
           document.getElementById('body').style.overflow = "hidden";
           document.body.scroll = "no";
        }
        else{
            document.getElementById('body').style.overflow = "visible";
            document.body.scroll = "yes";
        }
		
		document.getElementById('wrapper').style.width = "100%";
		document.getElementById('mainAreaContent').style.width = "100%";
		
	}
	
	else { 
		
		//When window minimize show scroller ===================================== 
		document.getElementById('body').style.overflow = "visible";
		document.body.scroll = "yes";
		//////////////////////////////////////////////////////////////////////////
		document.getElementById('wrapper').style.width = (g_pageMinWidth + 100) + "px";
		document.getElementById('mainAreaContent').style.width = (g_pageMinWidth + 100) + "px";
	}
	
}


function pageFooterStretchPositioning() {
    return;

	var currentResizedwidth;
	//////////////////////////////////////////////////////////////////////////

	currentResizedwidth = GetClientWidth();
	
	if (currentResizedwidth >= g_pageMinWidth) {
		var newWidthFooterMiddleBox;
		document.getElementById('footer_middlebox').style.width = currentResizedwidth - (g_pageMinWidth) + "px";
	}
	else { 
		document.getElementById('footer_middlebox').style.width = "0px";
	}
}

///////////////////////////////////////////


function errorAlert(errorMSG,errorField){
    document.getElementById(errorField).innerHTML = errorMSG;
}

// -- Validate Password : start ======================================================================== */
function validatePassword(password) {
    if(password.length < 6){
		return false; 
    }
    //because of "polkadot" and "zigzag" 
    return true;

	for(i=0; i<password.length; i++){
	    if( password.charAt(i) >= '0' && password.charAt(i) <= '9'){
			return true; 
		}
	}
	return false; 
   
}// -- end method
// -- Validate Password : end ========================================================================== */
    function HttpRequestAndFunction(url,target,functionid,w,h) {
		centerDivAbs(target,w,h);
		xmlHttpRequestCallFunctionCenter(url,target,functionid,w,h);
	}


///////////////////////////////////////////////////////
var divToScroll = '';
var scrollID = '';
var divStepToScroll = 0;
function startScrollDiv(id,step,sID){
	divStepToScroll = step;
	divToScroll = id;
	scrollID = sID;
	setTimeout("scrollDiv('"+id+"','"+sID+"')", 100);
}

function stopScrollDiv(){
	divToScroll = '';
	scrollID = '';
	divStepToScroll = 0;
}

function scrollDiv(id,sID){
	if(divStepToScroll == 0 || divToScroll != id || scrollID!=sID){
		return;
	}
	document.getElementById(divToScroll).scrollTop += divStepToScroll;
	setTimeout("scrollDiv('"+id+"','"+sID+"')", 100);
}
//////////////////////////////////////////////////////////	

function flashShow(divID,flashObj,vers){
    var pv=new PlayerVersion( vers.toString().split(".") );

    if(flashObj.installedVer.versionIsValid(pv)){		
        flashObj.write(divID);
    }
    else{
        var flashSwfObjDiv = document.getElementById(divID);
        var windowSizeHeight = GetClientHeight();
        var flashSwfObjDivHeight = windowSizeHeight - 100 - 347;
        flashObj.style.height = flashSwfObjDivHeight+'px';
        document.getElementById(divID).innerHTML = "<div align=\"center\" id=\"flashPlayerInstallPluginMessage\"><p style='margin:30px 0 5px 0;color:#ffffff;'>You must have the Flash Player 9 plug-in installed to view this site.</p><p><a href=\"http://www.adobe.com/go/getflashplayer\" target=\"_blank\"><img src=\"/images/get_flash_player_160x41.jpg\" alt=\"\" width=\"160\" height=\"41\" border=\"0\"></p></a></div>" ;	  
    }
}

function flashResize(divID,flashID,minHeight){

	var flashSwfObjInnerHTML= document.getElementById(divID).innerHTML
	if(!flashSwfObjInnerHTML.match("You must have the Flash Player 9 plug-in installed to view this site")) {
		var flashSwfObjDiv = document.getElementById(divID);
		var flashSwfObj = document.getElementById(flashID);
		var windowSizeHeight = GetClientHeight();
		
		var footer = 347; 
		var flashSwfObjDivHeight = windowSizeHeight - 100 - footer;
		if(flashSwfObjDivHeight >= minHeight) {
			flashSwfObj.style.height = flashSwfObjDivHeight+'px';
		    g_overflowHidden = true;
		}else {
			flashSwfObj.style.height = minHeight + 'px'; 
			//When window minimize show scroller ===================================== 
			//////////////////////////////////////////////////////////////////////////
		    g_overflowHidden = false;
		}
	}
}