﻿// JScript File

function SetCwinHeight(obj)   
{
	var cwin=obj;   
		if (document.getElementById)   
        {   
			var iHeight;
            if (cwin.contentDocument  && cwin.contentDocument.body.offsetHeight)
            { 
				iHeight = cwin.contentWindow.document.getElementById('country').offsetHeight + 200;
            }
            else if(cwin.Document && cwin.Document.body.scrollHeight)
            {   
				iHeight = cwin.Document.body.scrollHeight;
            }
            if (iHeight < 600)
            {
				iHeight = 600;
	        }
	         cwin.style.height = iHeight +'px';
        }   
}   

function SetProductNewsHeight(obj)   
{   
        var cwin=obj;   
        if (document.getElementById)   
        {   
                var iHeight=400;
                if (cwin.contentDocument  && cwin.contentDocument.body.offsetHeight){
					iHeight = cwin.contentWindow.document.getElementById('c3news').offsetHeight;
                }
                else if(cwin.Document && cwin.Document.body.scrollHeight)
                {   
					iHeight = cwin.Document.body.scrollHeight;
                }
                if (iHeight < 400)
                {
					iHeight = 400;
	            }
	            document.getElementById('c3news').style.height = iHeight +'px';
        }   
}

//Javascript change image for download button
function domRollover() {
	if (navigator.userAgent.match(/Opera (\S+)/)) {
		var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1]);
	}
	if (!document.getElementById||operaVersion <7) return;
	var imgarr=document.getElementsByTagName('img');
	var imgPreload=new Array();
	var imgSrc=new Array();
	var imgClass=new Array();

	for (i=0;i<imgarr.length;i++){
		if (imgarr[i].className.indexOf('domroll')!=-1)
		{
			imgSrc[i]=imgarr[i].getAttribute('src');
			imgClass[i]=imgarr[i].className;
			imgPreload[i]=new Image();
			if (imgClass[i].match(/domroll (\S+)/)) 
			{
				imgPreload[i].src = imgClass[i].match(/domroll (\S+)/)[1]
			}
			imgarr[i].setAttribute('xsrc', imgSrc[i]);
			imgarr[i].onmouseover=function()
			{
				this.setAttribute('src',this.className.match(/domroll (\S+)/)[1])
			}
			imgarr[i].onmouseout=function()
			{
				this.setAttribute('src',this.getAttribute('xsrc'))
			}
		}
	}
}

//default page check date
function IsValidVariable(Variable){
    try{
        eval(Variable);
        return   true;
    }
    catch(e){
        return   false;
    }
}

function ok_date(startdatestring,enddatestring){
    var startdate;
    var enddate;
    if(IsValidVariable(startdatestring) == true)
    {
		startdate = eval(startdatestring)
	};
    if(IsValidVariable(enddatestring) == true)
    {
		enddate = eval(enddatestring)
	};
    var thisDate = new Date();
    var tempDate = new Date();
    thisDate.setFullYear(tempDate.getUTCFullYear());
    thisDate.setMonth(tempDate.getUTCMonth());
    thisDate.setDate(tempDate.getUTCDate());
    thisDate.setHours(tempDate.getUTCHours());
    thisDate.setMinutes(tempDate.getUTCMinutes());

    var returnBoolean = false;
    if(typeof(startdate) != 'undefined' && typeof(enddate) != 'undefined')
    {
         if(startdate < thisDate && enddate > thisDate){
            returnBoolean = true;
         }
    }else if(typeof(startdate) != 'undefined' && typeof(enddate) == 'undefined'){
         if(startdate < thisDate){
            returnBoolean = true;
         }
    }else if(typeof(startdate) == 'undefined' && typeof(enddate) != 'undefined'){
         if(enddate > thisDate){
            returnBoolean = true;
         }
    }else if(typeof(startdate) == 'undefined' && typeof(enddate) == 'undefined'){
         returnBoolean = true;
    }
    return returnBoolean;
}

function convert_string_to_xml(strXML)
{
	if (window.ActiveXObject)
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
	    xmlDoc.loadXML(strXML);
		return xmlDoc;
	} else {
		parser=new DOMParser();
	    xmlDoc=parser.parseFromString(strXML,"text/xml");
	    return xmlDoc;
	}
} 
           
function CanResetLeftFlash(){
	var blnResult = false;
    if(IsIEBrowser()==true)
	{
		var obj = document.getElementById("liLeftNavi_Bar_Start");
		if(typeof(HasNewFalsh) !='undefined')
		{
			if(typeof(obj) != 'undefined')
			{ 
    			if(HasNewFalsh==true)
    		    {
    				blnResult = true; 
		        }  
		    }
		} 
    }
    return  blnResult;
}   

function ResizeLeftFalsh(){
    var xmlString = return_XML(); 
	if( typeof(xmlString) != 'undefined' && xmlString != '')
	{
		var strHref = window.location.href;
		var xmlDoc= convert_string_to_xml(xmlString);           		        
		var x = xmlDoc.getElementsByTagName('root'); 
		var firstItemCount = x[0].childNodes.length;
		var secondItemCount = 0;
		
		for(i = 0;i<firstItemCount;i++){
			var mainItem = x[0].childNodes[i];
			var subItemCount = mainItem.childNodes.length;
			
			if(subItemCount > 0){
				for(j=0;j<subItemCount;j++){
					var link = '';
					try{
						if(mainItem.childNodes[j].getAttribute("link") != null){
							link = mainItem.childNodes[j].getAttribute("link");
					    }
					}
					catch(e){
					
					}	
	
					if(typeof(link) != 'undefined' && link != '' && strHref.indexOf(link) > -1){
						secondItemCount = subItemCount;
					}
				}
			}
		}
		setFlashDivHeight(200,firstItemCount*44 + secondItemCount*26 + 25); 
	}
}

function setFlashDivHeight(start,end) { 
	var obj = document.getElementById("liLeftNavi_Bar_Start");
	if(obj != null && typeof(obj) != 'undefined')
    {
		if(IsIEBrowser()==true)
		{
			document.getElementById('liLeftNavi_Bar_Start').style.overflow = "hidden";
		} 
		if(hasRightVersion){
			MoveDiv = new Sequence();
			MoveDiv.addChild(new Tween(document.getElementById('liLeftNavi_Bar_Start').style, 'height', 
											Tween.strongEaseOut, start, end, 0.5, 'px'));
			MoveDiv.start(); 
		}
    }
} 

function IsIEBrowser(){
	var blnResult = false;
	var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var version=parseFloat(b_version);
    if (browser=="Microsoft Internet Explorer")
    {
		blnResult=true;	 
	}
	return blnResult; 
}







