var advertID = 0;
function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var browserName=navigator.appName; 
 if (browserName == "Microsoft Internet Explorer"){
	document.write('<style>');
	document.write('#menu ul li {');
		document.write('float: left;');
		document.write('width: 100%;');
	document.write('}');
	document.write('body {');
		document.write('behavior: url(/js/csshover.htc);');
		//document.write('font-size: 100%;');
	document.write('}');
	document.write('#menu ul li a {');
		document.write('height: 1%;');
	document.write('}');
	document.write('#menu a, #menu h2 {');
		document.write('font-family:verdana, Helvetica, sans-serif;');
	document.write('}');
	document.write('</style>');
}
function commenting(){
    click_get('?load=true'); 
}

var xmlhttp;
function loadXMLDoc(url){
    if (window.XMLHttpRequest){// code for Mozilla, etc.
      xmlhttp=new XMLHttpRequest();
      xmlhttp.onreadystatechange=xmlhttpChange;
      //alert(url);
      xmlhttp.open("GET",url,true);
      xmlhttp.send(null);
    }else if (window.ActiveXObject){// code for IE
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        if (xmlhttp){
            xmlhttp.onreadystatechange=xmlhttpChange;
            xmlhttp.open("GET",url,true);
            xmlhttp.send(null);
        }
    }
}

function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit){ // if too long...trim it!
        field.value = field.value.substring(0, maxlimit);
        // otherwise, update 'characters left' counter
    }else{
        countfield.value = maxlimit - field.value.length;
    }
}

function postXMLDoc(url,formname){
    if (window.XMLHttpRequest){// code for Mozilla, etc.
      xmlhttp=new XMLHttpRequest();
        if (xmlhttp){
            var fields = new Array();
            if(formname){
                var ajax = formname;
            }
            //loop through form elements and retrieve field NAMEs and Values
            for (var x = 0; x < eval("document."+ajax+".elements.length"); x++){
                // join them into a string.
                eval("fields.push(document."+ajax+".elements[x].name+'='+document."+ajax+".elements[x].value)");
            }
            elem = 'errors';
            //sendf looks like "username=myusername&password=mypass"
            var sendf = fields.join('&');
            
            
            xmlhttp.open("POST", url, true);
            xmlhttp.onreadystatechange=xmlhttpChange;
            xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//          xmlhttp.setRequestHeader('Content-Type', 'multipart/form-data');
            xmlhttp.send(sendf);                
        }
    }else if (window.ActiveXObject){// code for IE
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        if (xmlhttp){
            var fields = new Array();
            if(formname){
                var ajax = formname;
            }
            //loop through form elements and retrieve field NAMEs and Values
            for (var x = 0; x < eval("document."+ajax+".elements.length"); x++){
                // join them into a string.
                eval("fields.push(document."+ajax+".elements[x].name+'='+document."+ajax+".elements[x].value)");
            }
            elem = 'errors';
            //sendf looks like "username=myusername&password=mypass"
            var sendf = fields.join('&');
            
            
            xmlhttp.open("POST", url, true);
            xmlhttp.onreadystatechange=xmlhttpChange;
            xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//          xmlhttp.setRequestHeader('Content-Type', 'multipart/x-www-form-urlencoded');

            
            xmlhttp.send(sendf);                
        }
    }
}



function xmlhttpChange(){
//    alert(xmlhttp.status);
    if (xmlhttp.readyState==4){// if xmlhttp shows "loaded"
        if (xmlhttp.status==200){// if "OK"
            document.getElementById('comments').innerHTML = xmlhttp.responseText;
        
        /*
            //alert(xmlhttp.responseText);
            //eval(xmlhttp.responseText);
            var temp = new Array();
            temp = xmlhttp.responseText.split('|');
            if(temp[0] == 'script'){
                eval(temp[1]);
            }else{
                document.getElementById(temp[0]).innerHTML= temp[1];
            }
        */
        }else{
            alert("Problem retrieving data Comment Data")
        }
    }
}


function click_post(form_name){
    postXMLDoc('inc/savesharecomment.inc.php',form_name);
}
function click_get(query_str){
    loadXMLDoc('inc/savesharecomment.inc.php' + query_str);
}
/* Show Hide Function */
function hide_show(id){
    if(document.getElementById(id)){
        var it = document.getElementById(id);
    }
   if(it.style.visibility != 'hidden'){
        it.style.display = 'none';
        it.style.visibility = 'hidden';
   }else{
        it.style.display = 'block';
        it.style.visibility = 'visible';
   }
}
/* End of Show Hide Function */
