//mag
FuncOL = new Array();

function StkFunc(Obj) {
	FuncOL[FuncOL.length] = Obj;
}

function LoadAllStk() {
	for(i=0; i<FuncOL.length; i++) {
		FuncOL[i]();
	} 
}

if (window.attachEvent) window.attachEvent("onload",LoadAllStk);
else window.addEventListener("load",LoadAllStk,false);

function flash_write(content) {
	if (!hasReqestedVersion) {
		var alternateContent = "<div style='padding:15px;background:white;color:#333333;text-align:center;'>An old version of the Flash plugin was detected. <strong><a href=\"http://www.macromedia.com/go/getflash/\">Please upgrade your Flash plugin.</a></strong></div>";
		document.write(alternateContent);
	} else {
		document.write(unescape(content));
	}
}

function print_this_page(lg,cmpid,mode) {
	window.open("/_includes/print.php?lg="+lg+"&cmp_id="+cmpid+"&safe_mode="+mode,"myprint","toolbar=0");
	return false;
}


function send_mail(mail) {
	if (navigator.userAgent.indexOf('MSIE') != -1 ) {
		document.location.href="mailto:"+mail.replace(/#/g,"");
	} else {
		var xiframe=document.createElement("IFRAME");
		xiframe.style.display="none";
		xiframe.src="/_includes/xmailer.php?to="+mail.replace(/#/g,'');
		document.body.appendChild(xiframe);
	}
}

function ajax_refresh_captcha() {
	var xscript=document.createElement("SCRIPT");
	xscript.src="/_includes/scripts/ajax_refresh.php";
	document.body.appendChild(xscript);
}


function getTopPageScroll(){
	var y;
	if (self.pageYOffset) y = self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) y = document.documentElement.scrollTop;
	else if (document.body) y = document.body.scrollTop;

	return y;
}

var ddfield="";

function SetImageURL (url) {

	var img = new Image();
	img.src = url;

	w=img.width;
	h=img.height;

    var o = document.getElementById('SCS_fld_'+ddfield);
    o.value = url;
    
    var img = document.getElementById('SCS_image_'+ddfield); 
    img.src = '' + url;
           
    img.onload = function() {

             //alert(img.parentNode.parentNode.offsetWidth);
             if ( img.parentNode.parentNode.offsetWidth >= img.parentNode.parentNode.offsetHeight ){
                 //if (  )
                 img.style.width = img.parentNode.parentNode.offsetWidth + 'px';
                 img.style.height = 'auto';
             }
             else {
                 img.style.height = img.parentNode.parentNode.offsetHeight + 'px'; 
                 img.style.width = 'auto';                 
             }

             if ( img.offsetWidth < img.parentNode.parentNode.offsetWidth ) {
               img.style.width = img.parentNode.parentNode.offsetWidth + 'px';
               img.style.height = 'auto';
             }

             if ( img.offsetHeight < img.parentNode.parentNode.offsetHeight ) {
               img.style.height = img.parentNode.parentNode.offsetHeight + 'px';
               img.style.width = 'auto';
             }
    }
           
           /*
	var img = new Image();
	img.src = url;

	w=img.width;
	h=img.height;

    var o = document.getElementById('SCS_fld_'+ddfield);
    o.value = url;
    
    var img = document.getElementById('SCS_image_'+ddfield); 
    img.src = '' + url;
           
    if ( img.parentNode.offsetWidth >= img.parentNode.offsetHeight ){
         img.style.width = img.parentNode.offsetWidth + 'px';
         img.style.height = 'auto';
    } else {
         img.style.height = img.parentNode.offsetHeight + 'px'; 
         img.style.width = 'auto';                 
    }

    if ( img.offsetWidth < img.parentNode.offsetWidth ) {
         img.style.width = img.parentNode.offsetWidth + 'px';
         img.style.height = 'auto';
    }

    if ( img.offsetHeight < img.parentNode.offsetHeight ) {
               img.style.height = img.parentNode.offsetHeight + 'px';
               img.style.width = 'auto';
    }
    */


    img.style.top = '0px';
    img.style.left = '0px';

    img.setAttribute('orig', url);
    img.setAttribute('origwidth', w);
    img.setAttribute('origheight', h);
           
}