var sec_frame_height = "100px";
function initializeIndex(){
	var sec_frame = top.document.getElementById("sec_frame");
	sec_frame_height = sec_frame.style.height;
}
function openFrame(url,target,menuID){
	var frameName = "";
	switch(menuID){
		case 1:
		frameName = "sec_frame";
		break;
		case 2:
		frameName = "sub_sec_frame";
		break;
		case 3:
		frameName = "sub_sec_frame";
		break;
	}
	//var fr = target.frames[frameName];	
	//fr.location = url;	
}
function openPopup(url,w,h){
 if(w==undefined){
 	w=100;
 }
 if(h==undefined){
 	h=100;
 }
 var optionsPopup = "scrollbars=no,resizable=no,menubar=no,toolbar=no,location=no,width="+w+",height="+h+",top=50,left=50";
 var ow = window.open(url, "popup", optionsPopup);
 ow.focus();
}
function addFlashObj(param,loadingFlag,lPath){
	param.width = param.width==undefined?param.width="100%":param.width;
	param.height = param.height==undefined?param.height="100%":param.height;
	param.title = param.title==undefined?param.title="":param.title;
	param.salign =  param.salign==undefined?param.salign="lt":param.salign; 
	
	if(loadingFlag == undefined){
		loadingFlag = false;	
	}
	if(lPath == undefined){
		lPath = "";	
	}	
	if(param.param!=undefined){
		if(loadingFlag){			
			param.src=lPath+"loading.swf?SWF="+param.src+"&"+param.param;
		}else{
			param.src+="?"+param.param;
		}
	}else{
		if(loadingFlag){
			param.src=lPath+"loading.swf?SWF="+param.src;	
		}
	}
	var align_str = "";
	if(param.align != undefined){
		align_str = 'align="'+param.align+'"';		
	}
	param.id = param.id==undefined?"":param.id;
	
	document.write('<object id="'+param.id+'A" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+param.width+'" height="'+param.height+'" title="'+param.title+'">\n');
	document.write('<param name="movie" value="'+param.src+'">');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="scale" value="noscale"/>');
    document.write('<param name="salign" value="'+param.salign+'" />');	
	document.write('<param name="wmode" value="transparent"/>');
	document.write('<param name="menu" value="false"/>');
	document.write('<param name="allowscriptaccess" value="always"/>');	
	document.write('<embed id="'+param.id+'B" allowscriptaccess="always" menu="false" wmode="transparent" src="'+param.src+'" quality="high" scale="noscale" salign="'+param.salign+'" '+align_str+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+param.width+'" height="'+param.height+'"></embed>');
	document.write('</object>');		
}
//STRING FUNCTIONS
function toCurrency(val,decFlag){
	if(decFlag == undefined){
		decFlag = true
	}
	if(decFlag){
		val = Math.round(val*100)/100;
	}else{
		val = Math.round(val);
	}
	var out= "";
	val = String(val);
	var j = 0;
	var pointI = val.lastIndexOf('.');
	var floatPart  = "";
	var intPart = val;
	if(pointI>0){
		floatPart = val.substring(pointI+1,val.length); 
		intPart = val.substring(0,pointI);
	}
	for(var i = intPart.length; i>=0;i--){
		if(j<intPart.length-3 && (i-1)%3 == 0 ){			
			out+=intPart.substring(j,j+1);	
			out+=".";
		}else{
			out+=intPart.substring(j,j+1);		
		}
		j++
	}
	if(floatPart.length == 1){
		floatPart += "0"; 
	}else if(floatPart.length <=0){
		floatPart = "00";
	}
	if(decFlag){
		out += ","+floatPart
	}
	return out;
}
function currencyToVal(val){	
	var out = strReplace(".","",val);
	return Number(strReplace(",",".",out));
}
function strReplace(srcs,nstr,str){
	var remStr = str;
	var out ="";
	var pI;
	while(pI!=-1){
		pI = remStr.indexOf(srcs);
		if(pI != -1){
			out+=remStr.substr(0,pI)+nstr;
			remStr = remStr.substr(pI+1,remStr.length);		
		}else{
			out+=remStr;
		}
	}	
	return out;
}
//PRINT
function printPage(){
	window.print();
}

function setBGImg(id,url){	
	var d = document.getElementById(id);
	d.style.background='url('+url+')';
	//d.style.backgroundRepeat ='repeat-y';
	var out ="";
	for(var i in d.style){
		out+= i+" "+d.style[i]+"\n";			
	}
	//alert(out);
}
function initBGImgs(){		
	setBGImg("back_mid","imgs/main_mid.png");
}
function correctPNG() {	
  for(var i=0; i<document.images.length; i++)
      {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle        
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         //alert(img.outerHTML);
		 img.outerHTML = strNewHTML
         //alert(img.outerHTML);
		 i = i-1
         }
      }
}
function updateResize(){	
	/*
	var imgPath = top.imgPath;
	var mml =top.document.getElementById("main_mid_left");
	var mmr =top.document.getElementById("main_mid_right");
	mml.outerHTML = '<img id="main_mid_left" src="'+imgPath+'main_mid_left.png" width="3" height="100%" />';
	mmr.outerHTML = '<img id="main_mid_right" src="'+imgPath+'main_mid_right.png" width="3" height="100%" />';		
	*/	
	if(!top.correctPngFlag){
		/*
		var mml =top.document.getElementById("main_mid_left");
		var mmr =top.document.getElementById("main_mid_right");
	
		var mB = top.document.getElementById("mainMenuB");
		mml.height = mml.height+mB.height;
		mmr.height = mmr.height+mB.height;
		*/
		return;
	};
	
	top.correctPNG();	
	

}
var topMenuH
function resizePageH(val){
	if(val == undefined){
		val = top.sec_frame_height;	
	}
	var sec_frame = top.document.getElementById("sec_frame");
	sec_frame.style.height = val;	
	updateResize();
}
function setMenuHeight(val){
	var mc = top.document.getElementById("menuCont");
	mc.style.height = val;
	var mA = top.document.getElementById("mainMenuA");
	if(mA!=undefined){
		mA.height = val;	
	}
	var mB = top.document.getElementById("mainMenuB");
	if(mB!=undefined){
		mB.height = val;
	}
	updateResize();
}
function openLink(rel_url){
	var url = root_url+""+rel_url;
	top.document.location = url	
}
