
onerror = handleErr
var method;

function preventDrag(event) {
    if (event.type == 'dragenter' || event.type == 'dragover' || event.type == 'drop' || event.type == 'dragstart' || event.type == 'drag') {
        if (event.stopPropagation) //(Mozilla)
        {
            event.preventDefault();
            event.stopPropagation();
        }
        return false; //(IE)
    }
}

function handleErr(msg,url,l) {
    try {
        txt = "Line Number=" + l + "$#$#Errormessage=" + msg + " $#Method Name=" + method + "$#$# URL:" + url;
        if (method != 'noTrace')
            ClickHandler.LogError(txt);
    }
    catch (e) {
        
        }
    return true
}

//
// Configuration
//

//image to display the busy status
var loadingImage = new Image();
loadingImage.src = '../Private/images/loading.gif';	    	
var savingImage = new Image();
savingImage.src = '../Private/images/saving.gif';		    		
var frmWidth;
//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScrollFry()
{
 
	var yScroll;
    method = "getPageScrollFry";
    
	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;
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSizeFry(){
   
	var xScroll, yScroll;
	 method = "getPageSizeFry";
	
	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;
}





// open page in lightbox

function makemyControlVisible() {
    if (document.getElementById("divLgControl") != null) {
        document.getElementById("divLgControl").style.display = "block";
        if (document.getElementById("divSignup") != null)
            document.getElementById("divSignup").style.display = "block";
    }
}
function openFryshusetPageInLightBoxForSignUp(pageSrc) {

    method = "openFryshusetPageInLightBoxForSignUp";
    pageSrc = pageSrc.toLowerCase();
    try {
         if (document.getElementById("divLgControl") != null) {
                document.getElementById("divLgControl").style.display = "none";
                document.getElementById("divSignup").style.display = "none";
            }
        //get the DOM objects for loading the page in lightbox
        var objOverlay = document.getElementById('PageoverlayFry');
        objOverlay.style.position = 'absolute';
        objOverlay.style.top = '0';
        objOverlay.style.left = '0';
        objOverlay.style.width = '100%';
        objOverlay.style.height = '90%';
        objOverlay.style.zIndex = 0;
        var objLightbox = document.getElementById('PagelightboxFry');
        objLightbox.style.width = '880px';

        var objLoadingImage = document.getElementById('PageloadingImageFry');
        var objFrame = document.getElementById('PagelightboxFrameFry');

        // read the page size, window size and the scrolled position
        var arrayPageSize = getPageSize();
        var arrayPageScroll = getPageScroll();

        objOverlay.style.display = 'block';

        // center loadingImage if the loading image is set
        objLoadingImage.src = '../Private/images/loading.gif';
        objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
        objLoadingImage.style.left = (((arrayPageSize[0] - objLoadingImage.width) / 2) + 'px');
        objLoadingImage.style.display = 'block';
        if (document.getElementById("divWrapperLogin") != null)
            document.getElementById("divWrapperLogin").style.display = "none";

        // A small pause between the image loading and displaying is required with IE,
        // this prevents the previous image displaying for a short burst causing flicker.
        if (navigator.appVersion.indexOf("MSIE") != -1) {
            pause(250);
        }

        // IMPORTANT FOR DESIGNERS
        //setting the height and width of the iframe in which to display the page
          objFrame.height = '900px';
          objFrame.width = '880px';
          var h = 560;
          var w = 840;
      

        var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - h) / 2);
        var lightboxLeft = ((arrayPageSize[0] - 20 - w) / 2);
      //  objLightbox.style.left = lightboxLeft + "px";
        //objLightbox.style.top = lightboxTop + "px";


        // Setting source of the iframe
        objFrame.src = pageSrc;
        //hide the busy status
        if (objLoadingImage) {
            objLoadingImage.style.display = 'none';
        }
        arrayPageSize = getPageSize();
        objOverlay.style.height = (arrayPageSize[1] + 'px');

        //display the dimmed interface
        objLightbox.style.display = 'block';
    }
    catch (e) {

    }
}
// added by santosh
function openFryshusetPageInLightBox(pageSrc) {

    method = "openFryshusetPageInLightBox";
    var isIndex = false;  
    if(TemplateId!=0)
         isIndex=ClickHandler.getIsIndex(TemplateId).value;

     if (pageSrc.indexOf("MemberProfileInfo.aspx") < 0 && pageSrc.indexOf("unregister.aspx") < 0)
         pageSrc = "MemberStore/"+ pageSrc.toLowerCase();
     if (isIndex == false && pageSrc.indexOf("unregister.aspx") < 0)
        pageSrc = "../" + pageSrc;
        
      //For email popUp added by Samyukta
     if (isIndex == false && pageSrc.toLowerCase().indexOf("emailpopup.aspx") > -1)
     {
        pageSrc = "emailpopup.aspx";
        pageSrc = "../" + pageSrc;
     }      

    try
    {       
    // to hide all the videos and flash as well
    var embed = document.getElementsByTagName('object');
    if(embed != null)
    {
        for(var i=0; i <embed.length;i++)
        {
            embed[i].style.display = 'none';   
            embed[i].style.visibility = 'hidden'; 
        }  
     }
      
	//get the DOM objects for loading the page in lightbox
    var objOverlay = document.getElementById('PageoverlayFry');
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
 	objOverlay.style.width = '100%';
  	objOverlay.style.height = '90%'; 
	objOverlay.style.zIndex = 1;

	var objLightbox = document.getElementById('PagelightboxFry');
	objLightbox.style.width = 'auto';
	var objLoadingImage = document.getElementById('PageloadingImageFry');
	var objFrame = document.getElementById('PagelightboxFrameFry');
	// read the page size, window size and the scrolled position
	var arrayPageSizeFry = getPageSizeFry();
	var arrayPageScrollFry = getPageScrollFry();
	
	try
	{
	    //objFrame.height = parseInt(arrayPageSizeFry[1]);
	    objFrame.style.height = parseInt(arrayPageSizeFry[1])+"px";
//	  objLightbox.height = parseInt(arrayPageSize[1]) + 100 ;
//	  objOverlay.height = parseInt(arrayPageSize[1]) + 100 ;
	}
	catch(e)
	{
	}
 	objOverlay.style.display = 'block';
	
	// center loadingImage if the loading image is set
	    //objLoadingImage.src = '../../Private/images/loading.gif';
	objLoadingImage.style.top = (arrayPageScrollFry[1] + ((arrayPageSizeFry[3] - 35 - objLoadingImage.height) / 2) + 'px');
	objLoadingImage.style.left = (((arrayPageSizeFry[0] - objLoadingImage.width) / 2) + 'px');
		objLoadingImage.style.display = 'block';
	// A small pause between the image loading and displaying is required with IE,
	// this prevents the previous image displaying for a short burst causing flicker.
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		pause(250);
}
	
	var h = 310;
   	var w = 880;
   	//(added by Samyukta)
	if (pageSrc.indexOf('emailpopup') > -1) 
    {
	    var h = 400;
	    var w = 320;	
	}
   	var lightboxTop = arrayPageScrollFry[1] + ((arrayPageSizeFry[3] - h) / 2);
   	var lightboxLeft = ((arrayPageSizeFry[0] - 20 - w) / 2);
	objLightbox.style.left = lightboxLeft + "px";
	objLightbox.style.top = lightboxTop + "px";

    // Setting source of the iframe   
    objFrame.src = pageSrc;
	    
	//hide the busy status
	if (objLoadingImage) {	
		objLoadingImage.style.display = 'none';  
	}
	arrayPageSizeFry = getPageSizeFry();
	if ((pageSrc.indexOf("MemberProfileInfo.aspx") >= 0) && arrayPageSizeFry[1] < 1275)
	    objOverlay.style.height = "1300px";
	else {
	    if (arrayPageSizeFry[1] > 1275)
	        objOverlay.style.height = (arrayPageSizeFry[1] + 'px');
	        else
	            objOverlay.style.height = "1300px"; 
	}
	//alert(objOverlay.style.height);
	//display the dimmed interface
	objLightbox.style.display = 'block';
	if (pageSrc.indexOf("unregister.aspx") >= 0) {
	    objFrame.style.height = "340px"; 
	}
	 //added by Samyukta
	else if(pageSrc.toLowerCase().indexOf("emailpopup.aspx") > -1)
	{
	    objFrame.style.height = "400px";
	    objFrame.style.width = "320px";
	}  
	// Hide all flash while opening form in the lightbox
	if ($("div[id$='_SWF']") != null) {
	    $("div[id$='_SWF']").each(
    function(n) {
        $(this).hide();
    }
   )
	}
	
	}
	catch(e)
	{
	   
	}
}
// method to close the lightbox at public end

// method to close the lightbox at public end
function hideFryshusetLightboxInPublic() {
     method = "hideFryshusetLightboxInPublic";
     try{    
     
     // to show all the videos and flash as well
    var embed = document.getElementsByTagName('object');
    if(embed != null)
    {
    for(var i=0; i <embed.length;i++){
        embed[i].style.display = 'block';
        embed[i].style.visibility = 'visible';       
        }
    }
    
  
   
   
	// get objects
    objOverlay = document.getElementById('PageoverlayFry');
	if(objOverlay == null)
	    objOverlay = parent.document.getElementById('PageoverlayFry');

	objLightbox = document.getElementById('PagelightboxFry');	
	if(objLightbox == null)
	    objLightbox = parent.document.getElementById('PagelightboxFry');
	   
	
	// hide lightbox and overlay
	objOverlay.style.display = 'none';
	objLightbox.style.display = 'none';


    var gControlUpdate;
    if(typeof(IsSigningUpdateRequiredOnClosingLightBox) == "undefined")
        gControlUpdate = window.parent.IsSigningUpdateRequiredOnClosingLightBox;
    else
        gControlUpdate = IsSigningUpdateRequiredOnClosingLightBox;
        
    if(gControlUpdate)
     {       
        if(typeof(IsSigningUpdateRequiredOnClosingLightBox) == "undefined")
            window.parent.IsSigningUpdateRequiredOnClosingLightBox=false;
        else
            gControlUpdate = IsSigningUpdateRequiredOnClosingLightBox=false;
       
         if(parent.window.document.getElementById("signinsignout1_signin")!=null)
         {            
           parent.window.document.getElementById("signinsignout1_signin").style.display ="none";
           parent.window.document.getElementById("signinsignout1_join").style.display ="none";
           parent.window.document.getElementById("signinsignout1_signout").style.display ="block";
           parent.window.document.getElementById("signinsignout1_username").style.display ="block";
            parent.window.document.getElementById("signinsignout1_username").innerHTML = "V&auml;lkommen " + ClickHandler.GetCurrentUserName().value;
         }
         else
         {


             var signincontrolsElems = parent.window.document.getElementsByTagName('a');
             if (!FindSignInControlAndUpdate(signincontrolsElems)) {
                 signincontrolsElems = parent.window.parent.document.getElementsByTagName('a');
                 FindSignInControlAndUpdate(signincontrolsElems);
             }
             
             
         }
       }
       
       // finally emptying the source of the iframe
       var objFrame = document.getElementById('PagelightboxFrameFry');
       if(objFrame != null)
           objFrame.src = "";
       if (window.location.href.toLowerCase().indexOf("publiclogin.aspx") >= 0) {
           window.location.href = "../MemberStore/publiclogin.aspx";
       }

       // to show the flash objects 
       if ($("div[id$='_SWF']") != null) {
           $("div[id$='_SWF']").each(
        function(n) {
            $(this).show();
        }
       )
       }
       
	}
	catch(e)
	{

	}

}

