﻿var browserW,cindex=0,browser,oStatusDiv,PositionValue,arg,busy,exeTime,AdsCounter1 = 0,AdsCounter2 = 0,AdsCounter3 = 0,AdsCounter4 = 0,AdsCounter5 = 0,AdsTimer1,AdsTimer1a,AdsTimer2,AdsTimer2a,AdsTimer3,AdsTimer3a,AdsTimer4,AdsTimer4a,AdsTimer5,AdsTimer5a,AdsTimer6,flashTimer;
var dir1,dir2,dir3,dir4,dir5,obj1,obj2,obj3,obj4,obj5,extstyle,xmlTemp,xmlDoc,pos,counter1,counter2,counter3,counter4,counter5,xmlDoc1,xmlDoc2,xmlDoc3,rWay=0,adsarg,adsarg1,adsarg2,adsarg3,adsarg4,adsarg5,oDiv1,flashObj,NewFlashCSS,OldFlashCSS,arghl,sharedUrl;
var oDiv,pattern,oDiv2,oDiv3,oDivTicker,timer=null,elmTemp,dis,startindex,endindex,centeradd=false,centerElm;
function ResizeWindow(){
    //if((screen.availWidth/screen.availHeight) > 2){
    //    if(browserW != ((screen.availWidth/2) - 24)){            
    //    }
    //} else {
    //    if(browserW != (screen.availWidth  - 24)){            
    //    }
    //}
    if(centeradd){
        CenterElement(centerElm);
    }
    if(document.getElementById('TickerPanel')!=null){        
        document.getElementById('TickerPanel').style.top = (parseInt(document.getElementById('TickerPanel').previousSibling.style.top)+document.getElementById('TickerPanel').previousSibling.offsetHeight)+'px';
        document.getElementById('BodyPanel').style.top = (parseInt(document.getElementById('BodyPanel').previousSibling.style.top)+document.getElementById('BodyPanel').previousSibling.offsetHeight) +'px';        
    }
}
function FaceBookShared(url,image,title,summary){
    var newUrl,newObj,newTop,newLeft;
    newLeft = (browserW - 650)/2
    newTop = (browserH - 400)/2
    //alert(title);
    newObj = window.open('http://www.facebook.com/sharer.php?s=100&p[url]='+url+'&p[images][0]='+image+'&p[title]='+encodeURIComponent(title)+'&p[summary]='+encodeURIComponent(summary),'Facebook','scrollbars=0,toolbar=0,status=0,resizable=0,menubar=0,location=0,titlebar=0,height=400,width=650,left='+newLeft+',top='+newTop);
    //window.location.href = 'http://www.facebook.com/sharer.php?s=100&p[url]='+url+'&p[images][0]='+image+'&p[title]='+encodeURIComponent(title)+'&p[summary]='+encodeURIComponent(summary)
}

function VoteFunction(elm,temparg){    
    var obj,obj1,sCont1,curCount=elm.getAttribute('CurrentPos'),b,question=document.getElementById('NumberOfQuestions').value-1;
    sCont=true;
    arg='';    
    for(j=0;j<=question;j++){        
        b = j;        
        obj1 = document.getElementById('QAPanel'+String(j));
        sCont1 = false;
        for(i=0+cindex;i<obj1.childNodes.length-cindex*2;i++){
            if(obj1.childNodes[i].childNodes.length>0){
                var id = 'QA'+String(j),id1=obj1.childNodes[i].childNodes[0].id;
                if(id==id1){
                    if(obj1.childNodes[i].childNodes[0].checked==true){                        
                        sCont1=true;
                        arg=arg+'<item><F1>'+obj1.childNodes[i].childNodes[0].value+'</F1><F2>'+document.getElementById('PhoneArea').value+document.getElementById('PhonePrefix').value+document.getElementById('PhoneSuffix').value+'</F2></item>';
                    }
                }
            }
        };        
        if(sCont1==false){
            sCont=false;
            break;
        }
    };            
    if(sCont&&parseInt(curCount)==parseInt(question)){        
        if(busy==false){
            if(confirm('Submit your votes now?')){            
            arg='<root>'+arg+'</root>'+temparg;                          
            rWay=0;            
            for(i=0+cindex;i<document.getElementById('BodyPanel').childNodes.length-cindex;i++){
                document.getElementById('BodyPanel').childNodes[i].style.display='none';
            };
            document.getElementById('AdminTable').style.display='';
            oDiv=document.getElementById('AdminCell');
            StartProgressBar();            
            WebForm_DoCallback('__Page',arg,ReturnInLine,'',CallBackError,false);
            }
        } else {
            DisplayBusyMessage();
        }
    } else {
        if(b>question){            
            alert(document.getElementById('QAMsg').innerText);
        } else {            
            for(j=0;j<=question;j++){                
                document.getElementById('QAPanel'+String(j)).style.display='none';                
            }              
            obj1 = document.getElementById('QAPanel'+String(curCount));            
            sCont1 = false;
            for(i=0+cindex;i<obj1.childNodes.length-1-cindex;i++){
                if(obj1.childNodes[i].childNodes.length>0){
                    var id = 'QA'+String(curCount),id1=obj1.childNodes[i].childNodes[0].id;
                    if(id==id1){
                        if(obj1.childNodes[i].childNodes[0].checked==true){                        
                            sCont1=true;                            
                        }
                    }
                }
            };        
            if(sCont1){                
                if(curCount < question){                
                    curCount = parseInt(curCount) + 1
                }               
            }
            document.getElementById('QAPanel'+String(curCount)).style.display='';;
            if(curCount>0){
                elm.previousSibling.style.display='';
                elm.previousSibling.previousSibling.style.display='';
            } else {
                elm.previousSibling.style.display='none';
                elm.previousSibling.previousSibling.style.display='none';
            }
            elm.setAttribute('CurrentPos',curCount);
        }
    }
}


function ValidateEmail(email){
    var pos1,pos2;
    pos1 = email.value.indexOf("@");
    pos2 = email.value.lastIndexOf(".");
    if(pos1<1 || pos2<pos1+2 || pos2+2>=email.length){
        return false;
    } else {
        return true;
    }
}
function ValidateSubscription(){
    sCont = true;
    var email,prefix,suffix,seccode;
    email = document.getElementById('viaEmail');
    areacode = document.getElementById('viaSMS1');
    prefix = document.getElementById('viaSMS2');
    suffix = document.getElementById('viaSMS3');
    arg = '<root><item>'
    if(email.value==''&&((areacode.value==''&&prefix.value==''&&suffix.value=='') || (areacode.value=='999'&&prefix.value=='999'&&suffix.value=='9999'))){
        email.style.backgroundColor='yellow';
        areacode.style.backgroundColor='yellow';
        prefix.style.backgroundColor='yellow';
        suffix.style.backgroundColor='yellow';
        sCont=false;
    } else {
        email.style.backgroundColor='';
        areacode.style.backgroundColor='';
        prefix.style.backgroundColor='';
        suffix.style.backgroundColor='';
        if(email.value!=''){
            if(ValidateEmail(email)){
                arg = arg+'<F1>'+email.value+'</F1>';                
            } else {
                email.style.backgroundColor='yellow';
                sCont=false;        
            }
        } else {
            arg = arg+'<F1></F1>'; 
        }
        if(areacode.value!=''||prefix.value!=''||suffix.value!=''){
            if(areacode.value.length!=3||isNumeric(areacode.value)==false){
                areacode.style.backgroundColor='yellow';
                sCont=false;        
            } else {
                arg = arg+'<F2>'+areacode.value+'</F2>';
            }
            if(prefix.value.length!=3||isNumeric(prefix.value)==false){
                prefix.style.backgroundColor='yellow';
                sCont=false;        
            } else {
                arg = arg+'<F3>'+prefix.value+'</F3>';
            }
            if(suffix.value.length!=4||isNumeric(suffix.value)==false){
                suffix.style.backgroundColor='yellow';
                sCont=false;        
            } else {
                arg = arg+'<F4>'+suffix.value+'</F4>';
            }
        } else {
            arg = arg+'<F2></F2><F3></F3><F4></F4>'; 
        }
    }
    arg=arg+'</item></root>'  
}
function ValidateRegistration(){
    arg = '<root><item>'
    var email,firstname,lastname,areacode,prefix,suffix,seccode,agree,pos1,pos2;
    email = document.getElementById('RegisterEmail');
    firstname = document.getElementById('RegisterFirstName');
    lastname = document.getElementById('RegisterLastName');
    areacode = document.getElementById('RegisterAreaCode');
    prefix = document.getElementById('RegisterPrefix');
    suffix = document.getElementById('RegisterSuffix');
    seccode = document.getElementById('RegisterCode');
    agree = document.getElementById('RegisterAgreement');
    sCont = true;
    pos1 = email.value.indexOf("@");
    pos2 = email.value.lastIndexOf(".");
    if(ValidateEmail(email)==false){sCont = false;email.style.backgroundColor='yellow';} else {email.style.backgroundColor='';arg = arg+'<F1>'+email.value+'</F1>';};
    if(firstname.value==''||firstname.value==document.getElementById('FirstNameHidden').innerText){sCont=false;firstname.style.backgroundColor='yellow';} else {firstname.style.backgroundColor='';arg = arg+'<F2>'+firstname.value+'</F2>';}
    if(lastname.value==''||lastname.value==document.getElementById('LastNameHidden').innerText){sCont=false;lastname.style.backgroundColor='yellow';} else {lastname.style.backgroundColor='';arg = arg+'<F3>'+lastname.value+'</F3>';}
    arg = arg+'<F4>'+areacode.value+'</F4>';
    arg = arg+'<F5>'+prefix.value+'</F5>';
    arg = arg+'<F6>'+suffix.value+'</F6>';
    if(seccode.value==''){sCont=false;seccode.style.backgroundColor='yellow';} else {seccode.style.backgroundColor='';arg = arg+'<F7>'+seccode.value+'</F7><F8>'+seccode.getAttribute('hiddenvalue')+'</F8>';}
    if(agree.checked==false){sCont=false;agree.style.backgroundColor='yellow';} else {agree.style.backgroundColor='';}
    arg=arg+'</item></root>'  
}
function isEven(oNum) {
          return !(oNum % 2);
}
//Check to see if an element is matched with certain pattern
function IsMatch(id) 
    {
    var regularExpresssion = new RegExp(pattern);             
    if(id.match(regularExpresssion)) return true; 
    else return false; 
    }
//Check to see if an element is a checkbox
function isDate(oDate){
    var patterns = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;            
    patternArray=oDate.match(patterns);
    if(patternArray==null){               
        return false;
        }             
    if(patternArray[1] < 1 || patternArray[1] > 12){
        return false;
        }               
    if(patternArray[3] < 1 || patternArray[3] > 31){
        return false;
        }                        
    if((patternArray[1] == 4 || patternArray[1] == 6 || patternArray[1] == 9 || patternArray[1]== 11) && patternArray[3]==31){                                       
         return false;                   
        }
    if(patternArray==2 && (patternArray[1] > 29 || (patternArray[1]==29 && !(patternArray[5] % 4 == 0 && (patternArray[5] % 100 != 0 || patternArray[5] %400 ==0)))))
        {
            return false;
       }
     return true;
}
function IsCheckBox(chk) 
    {
    if(chk.type == 'checkbox') return true; 
    else return false;
    }
//Check to see if a value is a number
function isNumeric(oValue){            
    patterns = /^[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?$/;
    patternArray=oValue.match(patterns);
    if(patternArray==null){
        return false;
        }
    return true;
}
function CheckVideoEdit(){
	sCont=true;
	var title,cat,checked=false;
	arg = '<root>'
	title = document.getElementById('EditVideoTitle');
	cat = document.getElementById('EditVideoCat');
	var elements =  document.getElementsByTagName("INPUT");
	if(title.value==''){title.style.backgroundColor='yellow';sCont=false;} else {title.style.backgroundColor='';}
	for(i=0; i<elements.length;i++){    
	    if( IsCheckBox(elements[i]) && IsMatch(elements[i].id)){
	        if(elements[i].checked){
		        checked=true;
		        arg = arg+'<item><F1>'+title.value+'</F1><F2>'+cat.options[cat.selectedIndex].value+'</F2><F3>'+elements[i].value+'</F3></item>'
		    }
	    }
	}
    arg = arg+'</root>'	
	if(checked==false){		
		sCont = false;
	}
}
function ValidateProfile(){
    arg = '<root><item>'
    var areacode,prefix,suffix,currpwd,newpwd,newpwd1;    
    areacode = document.getElementById('RegisterAreaCode');
    prefix = document.getElementById('RegisterPrefix');
    suffix = document.getElementById('RegisterSuffix');
    currpwd = document.getElementById('CurrPwd');
    newpwd = document.getElementById('NewPwd');
    newpwd1 = document.getElementById('ConfirmPwd');
    sCont = true;    
    arg = arg+'<F1></F1><F2></F2><F3></F3>';    
    arg = arg+'<F4>'+areacode.value+'</F4>';
    arg = arg+'<F5>'+prefix.value+'</F5>';
    arg = arg+'<F6>'+suffix.value+'</F6>';
    if(currpwd.value==''){sCont=false;currpwd.style.backgroundColor='yellow';} else {currpwd.style.backgroundColor='';arg = arg+'<F7>'+currpwd.value+'</F7>';}
    if(newpwd.value!=newpwd1.value){sCont=false;newpwd.style.backgroundColor='yellow';newpwd1.style.backgroundColor='yellow';} else {newpwd.style.backgroundColor='';newpwd1.style.backgroundColor='';}
    if(newpwd.value==''){sCont=false;newpwd.style.backgroundColor='yellow';} else {newpwd.style.backgroundColor='';arg = arg+'<F8>'+newpwd.value+'</F8>';}    
    if(newpwd1.value==''){sCont=false;newpwd1.style.backgroundColor='yellow';} else {newpwd1.style.backgroundColor='';arg = arg+'<F9>'+newpwd1.value+'</F9>';}    
    arg=arg+'</item></root>'      
}
function DisplayBusyMessage(){
    alert('System is busy, please try back later');
}
function CenterElement(elm){     
    elm.style.left=(browserW - elm.offsetWidth)/2+'px';    
    if(navigator.userAgent.indexOf("MSIE 7")==-1){
        elm.style.top=((screen.availHeight - elm.offsetHeight - 150)/2)+'px';
    } else {
        elm.style.top=((screen.availHeight - elm.offsetHeight - 100)/2)+'px';
    }
}
function RefreshAds(){
    if(navigator.userAgent.indexOf("MSIE")==-1){
        adsvalue = (new XMLSerializer()).serializeToString(xmlDoc1);
    } else {
        adsvalue = xmlDoc1.xml;
    }        
    //GetAds();
}
function GetAds(){
    clearTimeout(AdsTimer1);
    clearTimeout(AdsTimer2);
    clearTimeout(AdsTimer3);
    clearTimeout(AdsTimer4);
    clearTimeout(AdsTimer5);
    clearTimeout(AdsTimer6);
    if(busy==false){
        arg=adsvalue+'EndOfString'+adsarg;
        rWay=8;
        //StartProgressBar();
        WebForm_DoCallback('__Page',arg,ReturnInLine,'',CallBackError,false);
    } else {
        DisplayBusyMessage();
    }
}
function HighLightTabs(elm,direction){
    if(direction==0){
        elm.setAttribute('class',elm.getAttribute('activeCSS'));
        document.body.style.cursor='hand';
    } else {
        elm.setAttribute('class',elm.getAttribute('currentCSS'));
        document.body.style.cursor='';
    }
}
function setTabs(elm,active,inactive,begin,range){                
     for(i=cindex+begin;i<cindex+begin+range;i++){                
        elm.parentNode.parentNode.childNodes[i].childNodes[browser].setAttribute('class',inactive);
        elm.parentNode.parentNode.childNodes[i].childNodes[browser].setAttribute('currentCSS',inactive)
     }
     elm.setAttribute('class',active);
     elm.setAttribute('currentCSS',active);
}
function LoadStream(elm){
    str = '<script type = "text/javascript" src = "http://www.tactrack.com/javascript/byntv.js"><\/script>'            
}
function GrayOut(sDisplay){    
    document.getElementById('GrayOutDiv').style.position=PositionValue;
    document.getElementById('GrayOutDiv').style.display=sDisplay;               
}
function CreateXMLForAdsStats(){
    if(navigator.userAgent.indexOf("MSIE")==-1){
        xmlDoc1=document.implementation.createDocument("","",null);
        var parser = new DOMParser();
        xmlDoc1 = parser.parseFromString("<root></root>","text/xml")
    } else {
        xmlDoc1=new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc1.async = "false";
        xmlDoc1.loadXML("<root></root>")
    }
    
}
function LoadAdsXML(arg){
    if(navigator.userAgent.indexOf("MSIE")==-1){
        xmlDoc=document.implementation.createDocument("","",null);
        var parser = new DOMParser();        
        xmlDoc = parser.parseFromString(arg,"text/xml");
        //xmlDoc.onload=readXML;
    } else {    
        //        
        xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async="false";        
        xmlDoc.loadXML(arg);
        
    }
}

function StartAds1(){    
    var start = false;
    clearTimeout(AdsTimer1);    
    if(AdsCounter1 >= xmlDoc.childNodes[0].childNodes[0].childNodes.length){
        AdsCounter1 = 0;
        while (xmlDoc.childNodes[0].childNodes[0].hasChildNodes()){
            xmlDoc.childNodes[0].childNodes[0].removeChild(xmlDoc.childNodes[0].childNodes[0].childNodes[0])
        }         
        if(busy==false){
            RefreshAds();
            arg=adsvalue+'EndOfString'+adsarg1;
            rWay=10;
            //StartProgressBar();
            WebForm_DoCallback('__Page',arg,ReturnInLine,'',CallBackError,false);
        } else {
            DisplayBusyMessage();
        }
    } else {        
        DisplayAds1()
        clearTimeout(AdsTimer1);
        AdsTimer1 = setTimeout("TurnOffAds1()",parseInt(xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1].childNodes[2].childNodes[0].nodeValue) * 1000)
    }
    
}
function StartAds2(){    
    var start = false;  
    clearTimeout(AdsTimer2);
    if(AdsCounter2 >= xmlDoc.childNodes[0].childNodes[1].childNodes.length){
        AdsCounter2 = 0;        
        while (xmlDoc.childNodes[0].childNodes[1].hasChildNodes()){
            xmlDoc.childNodes[0].childNodes[1].removeChild(xmlDoc.childNodes[0].childNodes[1].childNodes[0])
        }        
        if(busy==false){
            RefreshAds();
            arg=adsvalue+'EndOfString'+adsarg2;            
            rWay=12;
            
            WebForm_DoCallback('__Page',arg,ReturnInLine,'',CallBackError,false);
        } else {
            DisplayBusyMessage();
        }
    } else {
        DisplayAds2();        
        clearTimeout(AdsTimer2);
        AdsTimer2 = setTimeout("TurnOffAds2()",parseInt(xmlDoc.childNodes[0].childNodes[1].childNodes[AdsCounter2].childNodes[2].childNodes[0].nodeValue) * 1000)    
    }
}
function StartAds3(){    
    var start = false;  
    clearTimeout(AdsTimer3);
    if(AdsCounter3 >= xmlDoc.childNodes[0].childNodes[2].childNodes.length){
        AdsCounter3 = 0;        
        while (xmlDoc.childNodes[0].childNodes[2].hasChildNodes()){
            xmlDoc.childNodes[0].childNodes[2].removeChild(xmlDoc.childNodes[0].childNodes[2].childNodes[0])
        }        
        if(busy==false){
            RefreshAds();
            arg=adsvalue+'EndOfString'+adsarg3;            
            rWay=12;            
            WebForm_DoCallback('__Page',arg,ReturnInLine,'',CallBackError,false);
        } else {
            DisplayBusyMessage();
        }
    } else {
        DisplayAds3();        
        clearTimeout(AdsTimer3);
        AdsTimer3 = setTimeout("TurnOffAds3()",parseInt(xmlDoc.childNodes[0].childNodes[2].childNodes[AdsCounter3].childNodes[2].childNodes[0].nodeValue) * 1000)    
    }
}
function StartAds4(){    
    var start = false;  
    clearTimeout(AdsTimer4);
    if(AdsCounter4 >= xmlDoc.childNodes[0].childNodes[3].childNodes.length){
        AdsCounter4 = 0;        
        while (xmlDoc.childNodes[0].childNodes[3].hasChildNodes()){
            xmlDoc.childNodes[0].childNodes[3].removeChild(xmlDoc.childNodes[0].childNodes[3].childNodes[0])
        }        
        if(busy==false){
            RefreshAds();
            arg=adsvalue+'EndOfString'+adsarg4;            
            rWay=12;
            
            WebForm_DoCallback('__Page',arg,ReturnInLine,'',CallBackError,false);
        } else {
            DisplayBusyMessage();
        }
    } else {
        DisplayAds4();        
        clearTimeout(AdsTimer4);
        AdsTimer4 = setTimeout("TurnOffAds4()",parseInt(xmlDoc.childNodes[0].childNodes[3].childNodes[AdsCounter4].childNodes[2].childNodes[0].nodeValue) * 1000)    
    }
}
function StartAds5(){    
    var start = false;  
    clearTimeout(AdsTimer5);
    if(AdsCounter5 >= xmlDoc.childNodes[0].childNodes[4].childNodes.length){
        AdsCounter5 = 0;        
        while (xmlDoc.childNodes[0].childNodes[4].hasChildNodes()){
            xmlDoc.childNodes[0].childNodes[4].removeChild(xmlDoc.childNodes[0].childNodes[4].childNodes[0])
        }        
        if(busy==false){
            RefreshAds();
            arg=adsvalue+'EndOfString'+adsarg5;            
            rWay=12;
            
            WebForm_DoCallback('__Page',arg,ReturnInLine,'',CallBackError,false);
        } else {
            DisplayBusyMessage();
        }
    } else {
        DisplayAds5();        
        clearTimeout(AdsTimer5);
        AdsTimer5 = setTimeout("TurnOffAds5()",parseInt(xmlDoc.childNodes[0].childNodes[4].childNodes[AdsCounter5].childNodes[2].childNodes[0].nodeValue) * 1000)    
    }
}
function DisplayAds1(){              
    var nodeIndex,d    
    newNode = xmlDoc1.createElement("item")
    xmlDoc1.childNodes[0].appendChild(newNode);
    nodeIndex = xmlDoc1.childNodes[0].childNodes.length - 1;
    newNode = xmlDoc1.createElement("F1")    
    newNode.appendChild(xmlDoc1.createTextNode(xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1].childNodes[7].childNodes[0].nodeValue));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F2")        
    d = new Date();
    newNode.appendChild(xmlDoc1.createTextNode((d.getUTCMonth()+1).toString()+'/'+d.getUTCDate().toString()+'/'+d.getUTCFullYear().toString()+' '+d.getUTCHours().toString()+':'+d.getUTCMinutes().toString()+':'+d.getUTCSeconds().toString()));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F3")    
    newNode.appendChild(xmlDoc1.createTextNode(10));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F4")    
    newNode.appendChild(xmlDoc1.createTextNode(xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1].childNodes[10].childNodes[0].nodeValue));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    obj1 = document.getElementById(xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1].childNodes[4].childNodes[0].nodeValue);    
    obj1.innerHTML = xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1].childNodes[0].childNodes[0].nodeValue;
    obj1.style.visibility = 'visible';            
    counter1 = 1;
    dir1 = 0;    
    Fade1();    
}
function DisplayAds2(){    
    var nodeIndex,d;
    newNode = xmlDoc1.createElement("item")
    xmlDoc1.childNodes[0].appendChild(newNode);
    nodeIndex = xmlDoc1.childNodes[0].childNodes.length - 1;
    newNode = xmlDoc1.createElement("F1")       
    newNode.appendChild(xmlDoc1.createTextNode(xmlDoc.childNodes[0].childNodes[1].childNodes[AdsCounter2].childNodes[7].childNodes[0].nodeValue));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F2")        
    d = new Date();        
    newNode.appendChild(xmlDoc1.createTextNode((d.getUTCMonth()+1).toString()+'/'+d.getUTCDate().toString()+'/'+d.getUTCFullYear().toString()+' '+d.getUTCHours().toString()+':'+d.getUTCMinutes().toString()+':'+d.getUTCSeconds().toString()));    
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);   
    newNode = xmlDoc1.createElement("F3")    
    newNode.appendChild(xmlDoc1.createTextNode(10));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F4")       
    newNode.appendChild(xmlDoc1.createTextNode(xmlDoc.childNodes[0].childNodes[1].childNodes[AdsCounter2].childNodes[10].childNodes[0].nodeValue));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
         
    obj2 = document.getElementById(xmlDoc.childNodes[0].childNodes[1].childNodes[AdsCounter2].childNodes[4].childNodes[0].nodeValue);
    obj2.innerHTML = xmlDoc.childNodes[0].childNodes[1].childNodes[AdsCounter2].childNodes[0].childNodes[0].nodeValue;
    obj2.style.visibility = 'visible';            
    counter2 = 1;
    dir2 = 0;    
    Fade2();    
}
function DisplayAds3(){    
    var nodeIndex,d;
    newNode = xmlDoc1.createElement("item")
    xmlDoc1.childNodes[0].appendChild(newNode);
    nodeIndex = xmlDoc1.childNodes[0].childNodes.length - 1;
    newNode = xmlDoc1.createElement("F1")       
    newNode.appendChild(xmlDoc1.createTextNode(xmlDoc.childNodes[0].childNodes[2].childNodes[AdsCounter3].childNodes[7].childNodes[0].nodeValue));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F2")        
    d = new Date();        
    newNode.appendChild(xmlDoc1.createTextNode((d.getUTCMonth()+1).toString()+'/'+d.getUTCDate().toString()+'/'+d.getUTCFullYear().toString()+' '+d.getUTCHours().toString()+':'+d.getUTCMinutes().toString()+':'+d.getUTCSeconds().toString()));    
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);   
    newNode = xmlDoc1.createElement("F3")    
    newNode.appendChild(xmlDoc1.createTextNode(10));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F4")       
    newNode.appendChild(xmlDoc1.createTextNode(xmlDoc.childNodes[0].childNodes[2].childNodes[AdsCounter3].childNodes[10].childNodes[0].nodeValue));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
         
    obj3 = document.getElementById(xmlDoc.childNodes[0].childNodes[2].childNodes[AdsCounter3].childNodes[4].childNodes[0].nodeValue);
    obj3.innerHTML = xmlDoc.childNodes[0].childNodes[2].childNodes[AdsCounter3].childNodes[0].childNodes[0].nodeValue;
    obj3.style.visibility = 'visible';            
    counter3 = 1;
    dir3 = 0;    
    Fade3();    
}
function DisplayAds4(){    
    var nodeIndex,d;
    newNode = xmlDoc1.createElement("item")
    xmlDoc1.childNodes[0].appendChild(newNode);
    nodeIndex = xmlDoc1.childNodes[0].childNodes.length - 1;
    newNode = xmlDoc1.createElement("F1")       
    newNode.appendChild(xmlDoc1.createTextNode(xmlDoc.childNodes[0].childNodes[3].childNodes[AdsCounter4].childNodes[7].childNodes[0].nodeValue));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F2")        
    d = new Date();        
    newNode.appendChild(xmlDoc1.createTextNode((d.getUTCMonth()+1).toString()+'/'+d.getUTCDate().toString()+'/'+d.getUTCFullYear().toString()+' '+d.getUTCHours().toString()+':'+d.getUTCMinutes().toString()+':'+d.getUTCSeconds().toString()));    
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);   
    newNode = xmlDoc1.createElement("F3")    
    newNode.appendChild(xmlDoc1.createTextNode(10));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F4")       
    newNode.appendChild(xmlDoc1.createTextNode(xmlDoc.childNodes[0].childNodes[3].childNodes[AdsCounter4].childNodes[10].childNodes[0].nodeValue));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
         
    obj4 = document.getElementById(xmlDoc.childNodes[0].childNodes[3].childNodes[AdsCounter4].childNodes[4].childNodes[0].nodeValue);
    obj4.innerHTML = xmlDoc.childNodes[0].childNodes[3].childNodes[AdsCounter2].childNodes[0].childNodes[0].nodeValue;
    obj4.style.visibility = 'visible';            
    counter4 = 1;
    dir4 = 0;    
    Fade4();    
}
function DisplayAds5(){    
    var nodeIndex,d;
    newNode = xmlDoc1.createElement("item")
    xmlDoc1.childNodes[0].appendChild(newNode);
    nodeIndex = xmlDoc1.childNodes[0].childNodes.length - 1;
    newNode = xmlDoc1.createElement("F1")       
    newNode.appendChild(xmlDoc1.createTextNode(xmlDoc.childNodes[0].childNodes[4].childNodes[AdsCounter5].childNodes[7].childNodes[0].nodeValue));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F2")        
    d = new Date();        
    newNode.appendChild(xmlDoc1.createTextNode((d.getUTCMonth()+1).toString()+'/'+d.getUTCDate().toString()+'/'+d.getUTCFullYear().toString()+' '+d.getUTCHours().toString()+':'+d.getUTCMinutes().toString()+':'+d.getUTCSeconds().toString()));    
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);   
    newNode = xmlDoc1.createElement("F3")    
    newNode.appendChild(xmlDoc1.createTextNode(10));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
    newNode = xmlDoc1.createElement("F4")       
    newNode.appendChild(xmlDoc1.createTextNode(xmlDoc.childNodes[0].childNodes[4].childNodes[AdsCounter5].childNodes[10].childNodes[0].nodeValue));
    xmlDoc1.childNodes[0].childNodes[nodeIndex].appendChild(newNode);
         
    obj5 = document.getElementById(xmlDoc.childNodes[0].childNodes[4].childNodes[AdsCounter5].childNodes[4].childNodes[0].nodeValue);
    obj5.innerHTML = xmlDoc.childNodes[0].childNodes[4].childNodes[AdsCounter5].childNodes[0].childNodes[0].nodeValue;
    obj5.style.visibility = 'visible';            
    counter5 = 1;
    dir5 = 0;    
    Fade5();    
}
function Fade1(){
    var a,b    
    switch(dir1){
        case 0:            
            a = counter1 * 10
            b = counter1 * .1        
            document.getElementById(xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1].childNodes[4].childNodes[0].nodeValue).setAttribute("style",xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1].childNodes[5].childNodes[0].nodeValue+"filter:alpha(Opacity="+a.toString()+");opacity:"+b.toString()+";-moz-opacity:"+b.toString()+";-khtml-opacity:"+b.toString()+";")        
            break;
        case 1:            
            a = 100 - (counter1 * 10)
            b = 1 - (counter1 * .1)        
            document.getElementById(xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1].childNodes[4].childNodes[0].nodeValue).setAttribute("style",xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1].childNodes[5].childNodes[0].nodeValue+"filter:alpha(Opacity="+a.toString()+");opacity:"+b.toString()+";-moz-opacity:"+b.toString()+";-khtml-opacity:"+b.toString()+";")            
            break;
    }
    if(counter1 < 10){
        counter1 = counter1 + 1.5
        AdsTimer1a = setTimeout("Fade1()",100)
    } else {
        if(dir1==1){
            document.getElementById(xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1].childNodes[4].childNodes[0].nodeValue).style.visibility = 'hidden'
            AdsCounter1 = AdsCounter1 + 1;
            AdsTimer1 = setTimeout("StartAds1()",parseInt(xmlDoc.childNodes[0].childNodes[0].childNodes[AdsCounter1-1].childNodes[3].childNodes[0].nodeValue) * 1000)
        }
    }
}
function Fade2(){    
    var a,b
    clearTimeout(AdsTimer2a);    
    switch(dir2){
        case 0:            
            a = counter2 * 10
            b = counter2 * .1        
            obj2.setAttribute("style",xmlDoc.childNodes[0].childNodes[1].childNodes[AdsCounter2].childNodes[5].childNodes[0].nodeValue+"filter:alpha(Opacity="+a.toString()+");opacity:"+b.toString()+";-moz-opacity:"+b.toString()+";-khtml-opacity:"+b.toString()+";")        
            break;
        case 1:            
            a = 100 - (counter2 * 10)
            b = 1 - (counter2 * .1)        
            obj2.setAttribute("style",xmlDoc.childNodes[0].childNodes[1].childNodes[AdsCounter2].childNodes[5].childNodes[0].nodeValue+"filter:alpha(Opacity="+a.toString()+");opacity:"+b.toString()+";-moz-opacity:"+b.toString()+";-khtml-opacity:"+b.toString()+";")            
            break;
    }    
    if(counter2 < 10){
        counter2 = counter2 + 1.5
        AdsTimer2a = setTimeout("Fade2()",100)
    } else {
        if(dir2==1){
            obj2.style.visibility = 'hidden'
            AdsCounter2 = AdsCounter2 + 1;
            StartAds2();
        }
    }
}
function Fade3(){    
    var a,b
    clearTimeout(AdsTimer3a);    
    switch(dir3){
        case 0:            
            a = counter3 * 10
            b = counter3 * .1        
            obj3.setAttribute("style",xmlDoc.childNodes[0].childNodes[2].childNodes[AdsCounter3].childNodes[5].childNodes[0].nodeValue+"filter:alpha(Opacity="+a.toString()+");opacity:"+b.toString()+";-moz-opacity:"+b.toString()+";-khtml-opacity:"+b.toString()+";")        
            break;
        case 1:            
            a = 100 - (counter3 * 10)
            b = 1 - (counter3 * .1)        
            obj3.setAttribute("style",xmlDoc.childNodes[0].childNodes[2].childNodes[AdsCounter3].childNodes[5].childNodes[0].nodeValue+"filter:alpha(Opacity="+a.toString()+");opacity:"+b.toString()+";-moz-opacity:"+b.toString()+";-khtml-opacity:"+b.toString()+";")            
            break;
    }    
    if(counter3 < 10){
        counter3 = counter3 + 1.5
        AdsTimer3a = setTimeout("Fade3()",100)
    } else {
        if(dir3==1){
            obj3.style.visibility = 'hidden'
            AdsCounter3 = AdsCounter3 + 1;
            StartAds3();
        }
    }
}
function Fade4(){    
    var a,b
    clearTimeout(AdsTimer4a);    
    switch(dir4){
        case 0:            
            a = counter4 * 10
            b = counter4 * .1        
            obj4.setAttribute("style",xmlDoc.childNodes[0].childNodes[3].childNodes[AdsCounter4].childNodes[5].childNodes[0].nodeValue+"filter:alpha(Opacity="+a.toString()+");opacity:"+b.toString()+";-moz-opacity:"+b.toString()+";-khtml-opacity:"+b.toString()+";")        
            break;
        case 1:            
            a = 100 - (counter4 * 10)
            b = 1 - (counter4 * .1)        
            obj4.setAttribute("style",xmlDoc.childNodes[0].childNodes[3].childNodes[AdsCounter4].childNodes[5].childNodes[0].nodeValue+"filter:alpha(Opacity="+a.toString()+");opacity:"+b.toString()+";-moz-opacity:"+b.toString()+";-khtml-opacity:"+b.toString()+";")            
            break;
    }    
    if(counter4 < 10){
        counter4 = counter4 + 1.5
        AdsTimer4a = setTimeout("Fade4()",100)
    } else {
        if(dir4==1){
            obj4.style.visibility = 'hidden'
            AdsCounter4 = AdsCounter4 + 1;
            StartAds4();
        }
    }
}
function Fade5(){    
    var a,b
    clearTimeout(AdsTimer5a);    
    switch(dir5){
        case 0:            
            a = counter5 * 10
            b = counter5 * .1        
            obj5.setAttribute("style",xmlDoc.childNodes[0].childNodes[4].childNodes[AdsCounter5].childNodes[5].childNodes[0].nodeValue+"filter:alpha(Opacity="+a.toString()+");opacity:"+b.toString()+";-moz-opacity:"+b.toString()+";-khtml-opacity:"+b.toString()+";")        
            break;
        case 1:            
            a = 100 - (counter5 * 10)
            b = 1 - (counter5 * .1)        
            obj5.setAttribute("style",xmlDoc.childNodes[0].childNodes[4].childNodes[AdsCounter5].childNodes[5].childNodes[0].nodeValue+"filter:alpha(Opacity="+a.toString()+");opacity:"+b.toString()+";-moz-opacity:"+b.toString()+";-khtml-opacity:"+b.toString()+";")            
            break;
    }    
    if(counter5 < 10){
        counter5 = counter5 + 1.5
        AdsTimer5a = setTimeout("Fade5()",100)
    } else {
        if(dir5==1){
            obj5.style.visibility = 'hidden'
            AdsCounter5 = AdsCounter5 + 1;
            StartAds5();
        }
    }
}
function TurnOffAds1(){       
    clearTimeout(AdsTimer1);        
    counter1 = 1;
    dir1 = 1;
    Fade1();        
    
}
function TurnOffAds2(){        
    clearTimeout(AdsTimer2);        
    counter2 = 1;
    dir2 = 1;
    Fade2();    
        
}
function TurnOffAds3(){        
    clearTimeout(AdsTimer3);        
    counter3 = 1;
    dir3 = 1;
    Fade3();    
        
}

function TurnOffAds4(){        
    clearTimeout(AdsTimer4);        
    counter4 = 1;
    dir4 = 1;
    Fade4();    
        
}

function TurnOffAds5(){        
    clearTimeout(AdsTimer5);        
    counter5 = 1;
    dir5 = 1;
    Fade5();    
        
}

function FlashOnOffButton(){    
    clearTimeout(flashTimer);            
    if (flashObj.getAttribute('class')==NewFlashCSS){
        flashObj.setAttribute('class',OldFlashCSS);
    } else {
        flashObj.setAttribute('class',NewFlashCSS);
    }
    flashTimer = setTimeout("FlashOnOffButton()",1000);
}
function PlayYouTube(w,h,id){    
    document.getElementById('VideoPlayer').innerHTML = '<object width="'+w+'" height="'+h+'"><param name="movie" value="http://www.youtube.com/v/'+id+'&autoplay=1"><param name="wmode" value="opaque" /><param name="autoplay" value="start"/><PARAM name="quality" value="high"/></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed name = ""Test"" src="http://www.youtube.com/v/'+id+'&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+w+'" height="'+h+'" wmode="opaque"></embed></object>'    
    document.getElementById('VideoPlayer').focus();
    (document.documentElement || document.body).scrollTop = '0px';    
    document.getElementById('OnStream').style.display='';
    NewFlashCSS = 'gradcurve4CGreenTopBottom'
    flashObj = document.getElementById('OnStreamPanel');
    flashTimer = setTimeout("FlashOnOffButton()",1000);
    document.getElementById('OffStream').style.display='none';    
}
function PlayYouTubeDyn(w,h,id,player){    
    player.innerHTML = '<object width="'+w+'" height="'+h+'"><param name="movie" value="http://www.youtube.com/v/'+id+'&autoplay=1"><param name="wmode" value="opaque" /><param name="autoplay" value="start"/><PARAM name="quality" value="high"/></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed name = ""Test"" src="http://www.youtube.com/v/'+id+'&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+w+'" height="'+h+'" wmode="opaque"></embed></object>'    
}
function ReturnInLine(arg,context){     
    switch(arg){
        case 'Authentication':
            StopProgressBar(); 
            window.location.href='';
            return false;                    
            break;
        case 'Completed':
            StopProgressBar(); 
            alert(arg);
            break;
        case 'Error!':
            if(document.getElementById('TxnStatus')!=null){
                document.getElementById('TxnStatus').style.color='red';
                document.getElementById('TxnStatus').innerHTML = 'Error!  An error was generated and stored in the error table.';
            } else {
                alert('Error!  An error was generated and stored in the error table.');
            }
            StopProgressBar(); 
            break;                 
        default:
            switch(rWay){
                case 0:                                        
                    oDiv.innerHTML=arg;
                    StopProgressBar();
                    break;
                case 2:                    
                    oDiv.innerHTML=arg;
                    StopProgressBar();   
                    if(browserW<document.getElementById('MainDiv').offsetWidth){
                        browserW = document.getElementById('MainDiv').offsetWidth;
                    }
                    ResizeWindow();                    
                    break;
                case 8:                                                            
                    CreateXMLForAdsStats();
                    LoadAdsXML(arg);
                    AdsTimer1 = setTimeout("StartAds1();", 2000);
                    AdsTimer2 = setTimeout("StartAds2();",2000);                    
                    break;                    
                case 10:                    
                    var cloneNode;
                    if(navigator.userAgent.indexOf("MSIE")==-1){
                        xmlDoc2=document.implementation.createDocument("","",null);
                        var parser = new DOMParser();        
                        xmlDoc2 = parser.parseFromString(arg,"text/xml");                        
                    } else {    
                        //        
                        xmlDoc2=new ActiveXObject("Microsoft.XMLDOM");
                        xmlDoc2.async="false";        
                        xmlDoc2.loadXML(arg);
                        
                    }
                    for(i=0;i<xmlDoc2.childNodes[0].childNodes[0].childNodes.length;i++){
                        cloneNode = xmlDoc2.childNodes[0].childNodes[0].childNodes[i].cloneNode(true);                        
                        xmlDoc.childNodes[0].childNodes[0].appendChild(cloneNode)
                    }
                    xmlDoc2 = null;
                    AdsTimer1 = setTimeout("StartAds1();", 100);                    
                    break;
                case 12:
                    var cloneNode;                    
                    AdsCounter2 = 0
                    if(navigator.userAgent.indexOf("MSIE")==-1){
                        xmlDoc3=document.implementation.createDocument("","",null);
                        var parser = new DOMParser();        
                        xmlDoc3 = parser.parseFromString(arg,"text/xml");                        
                    } else {                            
                        xmlDoc3=new ActiveXObject("Microsoft.XMLDOM");
                        xmlDoc3.async="false";        
                        xmlDoc3.loadXML(arg);
                        
                    }                    
                    for(i=0;i<xmlDoc3.childNodes[0].childNodes[1].childNodes.length;i++){
                        cloneNode = xmlDoc3.childNodes[0].childNodes[1].childNodes[i].cloneNode(true);                        
                        xmlDoc.childNodes[0].childNodes[1].appendChild(cloneNode)
                    }                                        
                    xmlDoc3 = null;
                    AdsTimer2 = setTimeout("StartAds2();", 100);                    
                    break;
                case 14:                          
                    busy=false;           
                    oStatusDiv.style.display='none';
                    document.body.style.cursor='';
                    oDiv.style.display='';
                    oDiv.style.position = PositionValue;
                    oDiv.innerHTML=arg;                    
                    CenterElement(oDiv);                    
                    oDiv.style.zIndex = '1000';
                    break;
                case 16:                                                            
                    busy=false;           
                    oStatusDiv.style.display='none';
                    document.body.style.cursor='';                    
                    oDiv1.innerText=arg;                    
                    break;
                case 18:                    
                    oDiv.innerHTML=arg;
                    StopProgressBar();
                    (document.documentElement || document.body).scrollTop = '250px';
                    break;
                case 20:                    
                    break;
                case 22:                    
                    document.body.style.cursor='';                    
                    oDivTicker.innerHTML=arg;
                    oDivTicker.childNodes(0).start();
                    break;
                case 24:                          
                    busy=false;           
                    oStatusDiv.style.display='none';
                    document.body.style.cursor='';
                    oDiv1.style.display='';
                    oDiv1.style.position = PositionValue;
                    oDiv1.innerHTML=arg;                    
                    CenterElement(oDiv1);                    
                    oDiv1.style.zIndex = '1000';
                    break;
                case 26:
                    oDiv.innerHTML=arg;
                    AdsTimer1 = setTimeout("GetAds();", 5000);
                    break;
                case 28:                                                                                
                    busy=false;           
                    oStatusDiv.style.display='none';
                    document.body.style.cursor='';                    
                    oDiv.innerText=arg;                    
                    break;
                case 30:                          
                    busy=false;           
                    oStatusDiv.style.display='none';
                    document.body.style.cursor='';
                    oDiv2.style.display='';
                    oDiv2.style.position = PositionValue;
                    oDiv2.innerHTML=arg;                    
                    CenterElement(oDiv2);                    
                    oDiv2.style.zIndex = '1000';
                    break;
                case 32:                                                            
                    busy=false;           
                    oStatusDiv.style.display='none';
                    document.body.style.cursor='';                    
                    oDiv2.innerText=arg;                    
                    break;  
                case 34:      
                    var val;
                    val = arg.split('SplitString')
                    for(i=0;i<val.length;i++){
                        document.getElementById(val[i]).innerHTML = val[i+1];
                        i=i+1;
                    }
                    StopProgressBar();
                    break;              
            }
            break;
    }
}
//LoadAdsArray();

