///(c) IAM, LIPFEED.COM 2010, ALL RIGHTS RESERVED
///(c) IAM, LIPFEED.COM 2010, ALL RIGHTS RESERVED
///(c) IAM, LIPFEED.COM 2010, ALL RIGHTS RESERVED
///(c) IAM, LIPFEED.COM 2010, ALL RIGHTS RESERVED


function changetype(obj){
var passwo=document.createElement('input');
passwo.setAttribute('type','password');
passwo.setAttribute('size','9');
passwo.setAttribute('name',obj.getAttribute('name'));
passwo.style.fontSize = "80%";
obj.parentNode.replaceChild(passwo,obj);
passwo.select();
}



function validatemes(txtcheck,maxLength){if(txtcheck.value.length > maxLength){txtcheck.value = txtcheck.value.substr(0,maxLength);}}




function bookmarklipfeed(url){
var title = document.title;

   if (document.all)
     window.external.AddFavorite(url, title);
   else if (window.sidebar)
     window.sidebar.addPanel(title, url, "")
   else if (window.sidebar&&window.sidebar.addPanel)
     window.sidebar.addPanel(title,url,"");
}







function ajax(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Connection Lost");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){

            if(ajaxRequest.readyState == 1){
                      //objParent=document.getElementById('half');
			 //objParent.innerHTML= '<img src="/images/ajax.gif" >';
                      
		}

		if(ajaxRequest.readyState == 4){
                     
                      objParent=document.getElementById('half');
                      
			 //objParent.innerHTML= ajaxRequest.responseText;
                //objParent.innerHTML= ajaxRequest.responseText  ;
                 
                   eval(ajaxRequest.responseText);  
                                    
		}
	}
	ajaxRequest.open("GET", "ajax.php?"+"&t="+Math.random(), true);
	ajaxRequest.send(null); 

//setTimeout('ajax();', 10000);

}




function findmisswannabee(){ var sm = window.open ("/apps/treasurehunt.php?","treasurehunt","location=0,status=0,scrollbars=1,left=100,top=100,width=800,height=700"); advertise.focus();return false; }



function addborder(elem){ 
return true; 
elem.style.border='6px none #FF0000';
elem.style.width='85%';
elem.style.height='85%';
}

function removeborder(elem){
return true;
elem.style.border='0px solid ';
elem.style.width='95%';
elem.style.height='95%';
}



function loadimage(){
previewimg = document.getElementById("previewit");
previewimgsrc = document.getElementById("imgurl");
if(previewimgsrc.src!=null ){
previewimg.style.height='auto';previewimg.src=previewimgsrc.value; previewimg.style.visibility='visible'; previewimg.style.width='85%'; 
}else{
previewimg.style.height='0%';previewimg.src=previewimgsrc.value; previewimg.style.visibility='hidden'; previewimg.style.width='0%'; 
}
}

function loadimageit(thise){
document.getElementById("imgurl").value=thise.src;
}


function showpaywindow(){
var advertise = window.open ("/tills/pay.php?","paywindow","location=0,status=0,scrollbars=1,left=150,top=150,width=300,height=300"); 
advertise.focus();
return false;
}

function terms(link){
var terms = window.open (""+link+"","terms_window","location=0,status=0,scrollbars=1,left=150,top=150,width=800,height=500"); 
terms.focus();
return false;


}

function showpaypalwindow(amount,price){
//publishbox();
var link = "/tills/createpaypal.php?amount="+amount+"&price="+price;
var paypal = window.open (""+link+"","Paypal_window","location=0,status=0,scrollbars=1,left=100,top=150,width=900,height=500"); 
//paypal.style.width='100%';
//paypal.style.height='100%';

paypal.focus();
return false;
}


function showpaypalwindow2(amount,price,prom){
//publishbox();
var link = "/tills/createpaypal.php?amount="+amount+"&price="+price+"&prom="+prom;
var paypal = window.open (""+link+"","Paypal_window","location=0,status=0,scrollbars=1,left=100,top=150,width=900,height=500"); 
//paypal.style.width='100%';
//paypal.style.height='100%';

paypal.focus();
return false;
}






function advertbox(){
infoboxx = document.getElementById("advertbox"); 

if(infoboxx.style.visibility=="hidden"){
postadvert('', 'a');
infoboxx.style.visibility="visible";
infoboxx.style.position="relative";
infoboxx.style.height="auto";


infoboxx = document.getElementById("sendbox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";



infoboxx = document.getElementById("passwordbox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";

infoboxx = document.getElementById("theadvert"); 
infoboxx.style.display="none";


}else{
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
infoboxx.innerHTML="";
infoboxx = document.getElementById("theadvert"); 
infoboxx.style.display="";
}
}




function passwordbox(){
ajax();

infoboxx = document.getElementById("passwordbox"); 

if(infoboxx.style.visibility=="hidden"){
infoboxx.style.visibility="visible";
infoboxx.style.position="relative";
infoboxx.style.height="auto";
infoboxx = document.getElementById("sendbox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
infoboxx = document.getElementById("advertbox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
infoboxx.innerHTML="";

infoboxx = document.getElementById("theadvert"); 
infoboxx.style.display="none";

}else{
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
infoboxx = document.getElementById("theadvert"); 
infoboxx.style.display="";
}
}



function sendbox(){
ajax();
infoboxx = document.getElementById("sendbox"); 
if(infoboxx.style.visibility=="hidden"){
infoboxx.style.visibility="visible";
infoboxx.style.position="relative";
infoboxx.style.height="auto";
infoboxx = document.getElementById("passwordbox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
infoboxx = document.getElementById("advertbox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
infoboxx.innerHTML="";
infoboxx = document.getElementById("theadvert"); 
infoboxx.style.display="none";

}else{
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
infoboxx = document.getElementById("theadvert"); 
infoboxx.style.display="";
}
}


function sendboxsend(){
window.location = "http://www.lipfeed.com/"+document.getElementById("sendboxusername").value+"/contact/";
}


function sharebox(){


infoboxx = document.getElementById("sharebox"); 

if(infoboxx.style.visibility=="hidden"){
infoboxx.style.visibility="visible";
infoboxx.style.position="relative";
infoboxx.style.height="auto";
infoboxx = document.getElementById("messagebox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";

//infoboxx = document.getElementById("theadvert"); 
//infoboxx.style.display="none";
}else{
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
//infoboxx = document.getElementById("theadvert"); 
//infoboxx.style.display="";
}
ajax();
}





function setbox(){
infoboxx = document.getElementById("setbox"); 

if(infoboxx.style.visibility=="hidden"){
infoboxx.style.visibility="visible";
infoboxx.style.position="relative";
infoboxx.style.height="auto";
infoboxx = document.getElementById("messagebox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";

infoboxx = document.getElementById("sharebox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";



}else{
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
}
ajax();
}



function messagebox(){

infoboxx = document.getElementById("messagebox"); 

if(infoboxx.style.visibility=="hidden"){
infoboxx.style.visibility="visible";
infoboxx.style.position="relative";
infoboxx.style.height="auto";
infoboxx = document.getElementById("sharebox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";



//infoboxx = document.getElementById("theadvert"); 
//infoboxx.style.display="none";


}else{
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
//infoboxx = document.getElementById("theadvert"); 
//infoboxx.style.display="";



}
ajax();
}


function publishbox(){


infoboxx = document.getElementById("publish_box"); 

if(infoboxx.style.visibility=="hidden"){
infoboxx.style.visibility="visible";
infoboxx.style.position="relative";
infoboxx.style.height="auto";
infoboxx = document.getElementById("sharebox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";
infoboxx = document.getElementById("messagebox"); 
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%"




}else{
infoboxx.style.visibility="hidden";
infoboxx.style.position="absolute";
infoboxx.style.height="0%";





}
ajax();
}









function search(){

ajax();
var ajaxRequest;
try{
ajaxRequest = new XMLHttpRequest();
} catch (e){
try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert("Connection Lost");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
                      objParent=document.getElementById('searchbox');
			 objParent.innerHTML= ''+ajaxRequest.responseText;
		}

       }

       if(document.getElementById('searchquery').value){
       searchvalue = document.getElementById('searchquery').value;  
       }else{
       return false;
       }
       objParent=document.getElementById('searchbox');
	objParent.innerHTML=  '<img src="/images/ajax.gif" > Searching...<br>';            
       searchvalue=searchvalue.replace(".", "+");
	ajaxRequest.open("GET", "/tools/searchfor.php?descrip="+escape(searchvalue), true);
	ajaxRequest.send(null); 
}


function savepassword(myform ){
      var params="password="+document.getElementById("password").value;
     var url="/tools/settings.php";
   var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', url, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {

        if (self.xmlHttpReq.readyState ==1 ) {
        document.getElementById('passwordboxsubmit').style.display="none";
            document.getElementById('passwordboxinfo').innerHTML = '<img src="/images/ajax.gif" ><br>';
        }
 
       
        if (self.xmlHttpReq.readyState == 4) {
            document.getElementById('passwordboxinfo').innerHTML = self.xmlHttpReq.responseText;
           var t=setTimeout("closepasswordalert()",5000);

        }
    }
    self.xmlHttpReq.send(params);
}






function closepasswordalert(elem){
document.getElementById('passwordboxinfo').innerHTML='';
document.getElementById('passwordboxsubmit').style.display="inline";
}



function postmessage(myform , user){

      var params="message="+document.getElementById("composetext").value+"&user="+user;
     var url="/tools/compose.php";
document.getElementById("composetext").value = '';
   var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', url, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {

        if (self.xmlHttpReq.readyState ==1 ) {
             document.getElementById(myform+'submit').innerHTML = '';
            document.getElementById(myform+'info').innerHTML = '<img src="/images/ajax.gif" >';
        }
 
        if (self.xmlHttpReq.readyState == 4) {
            document.getElementById(myform+'info').innerHTML = self.xmlHttpReq.responseText;
           var t=setTimeout("closemessagealert()",5000);

        }
    }
    self.xmlHttpReq.send(params);
}






function closemessagealert(elem){
document.getElementById('messageboxinfo').innerHTML='';
document.getElementById('messageboxsubmit').innerHTML = '&nbsp;SEND MESSAGE&nbsp;';
}


function removeNL(s) {
  r = "";
  for (i=0; i < s.length; i++) {
    if (s.charAt(i) != '\n' &&
        s.charAt(i) != '\r' &&
        s.charAt(i) != '\t') {
      r += s.charAt(i);
      }
    }
  return r;
  }



function postadvert(myform , type){
ajax();
if(type=="b"){ 

var params="link="+escape(document.getElementById("link").value)+"&descrip="+ escape(document.getElementById("descrip").value)+"&url="+ escape(document.getElementById("imgurl").value)+"&embedcode="+ escape(document.getElementById("embedcode").value);
document.getElementById('advertboxstatus').innerHTML = "&nbsp;<img src=\"/images/ajax.gif\">&nbsp;";


}

if(type=="c"){ 
scroll(0,0);

var params="link="+escape(document.getElementById("link").value)+"&descrip="+ escape(document.getElementById("descrip").value)+"&url="+ escape(document.getElementById("imgurl").value)+"&embedcode="+ escape(document.getElementById("embedcode").value)+"&captcha="+ escape(document.getElementById("captcha").value);

document.getElementById('advertboxsubmit').innerHTML = "&nbsp;<img src=\"/images/ajax.gif\">&nbsp;";

}

///document.getElementById('advertbox').innerHTML= '<img src="/images/ajax.gif" >';
     var url="/tills/createajax.php?"+Math.random();
   var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', url, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {

        if (self.xmlHttpReq.readyState ==1 ) {
        }
 
       
        if (self.xmlHttpReq.readyState == 4) {
           if(type=="a"){ 
           document.getElementById('advertbox').innerHTML = removeNL(self.xmlHttpReq.responseText);

           }
 
            if(type=="b"){ 
                       

            document.getElementById('advertbox').innerHTML = removeNL(self.xmlHttpReq.responseText);



            }

            if(type=="c"){ 
                       

            document.getElementById('advertbox').innerHTML = removeNL(self.xmlHttpReq.responseText);



            }

        }
    }
    self.xmlHttpReq.send(params);

}




function postagentform(myform , type){

if (document.getElementById("q") && document.getElementById("prom") ){


var e=document.getElementsByName('paymentmethod');
if (e[0].checked){
var payedby = e[0].value; 
} 
if (e[1].checked){
var payedby = e[1].value; 
}

if (e[2].checked){
var payedby = e[2].value; 
}

if (e[3].checked){
var payedby = e[3].value; 
}


if (e[4].checked){
var payedby = e[4].value; 
}

var params="paymentmethod="+escape(payedby)+"&statement="+escape(document.getElementById("statement").value)+"&q="+escape(document.getElementById("q").value)+"&prom="+escape(document.getElementById("prom").value)+"&customername="+escape(document.getElementById("customername").value)+"&authcustomername="+escape(document.getElementById("authcustomername").value)+"&customeraddress1="+escape(document.getElementById("customeraddress1").value)+"&customeraddress2="+escape(document.getElementById("customeraddress2").value)+"&customercounty="+escape(document.getElementById("customercounty").value)+"&customerpostcode="+escape(document.getElementById("customerpostcode").value)+"&customercountry="+escape(document.getElementById("customercountry").value)+"&customertele="+escape(document.getElementById("customertele").value)+"&customernotes="+escape(document.getElementById("customernotes").value);

document.getElementById('gobutton').style.display="none";
}else{

document.getElementById("orderforminfo").innerHTML = "Please select quantity";
return false;
}



///document.getElementById('advertbox').innerHTML= '<img src="/images/ajax.gif" >';
     var url="/tools/agentform.php?"+Math.random();
   var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', url, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {

        if (self.xmlHttpReq.readyState ==1 ) {
        }
 
       
        if (self.xmlHttpReq.readyState == 4) {

document.getElementById('gobutton').style.display="inline";

document.getElementById("orderforminfo").innerHTML = removeNL(self.xmlHttpReq.responseText);
//alert(removeNL(self.xmlHttpReq.responseText));
//window.location = removeNL(self.xmlHttpReq.responseText);
 


        }
    }
    self.xmlHttpReq.send(params);

}












function postlink(myform){
ajax();

      var params="email="+document.getElementById("advertsemail").value;
     var url="/tools/send.php";
document.getElementById("advertsemail").style.fontColor = 'grey';
document.getElementById("advertsemail").value = 'Email Address';
   var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', url, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {

        if (self.xmlHttpReq.readyState ==1 ) {
       document.getElementById('shareboxsubmit').innerHTML ='';
            document.getElementById(myform+'info').innerHTML = '<img src="/images/ajax.gif" >';
        }
 
       
        if (self.xmlHttpReq.readyState == 4) {
            document.getElementById('shareboxinfo').innerHTML = self.xmlHttpReq.responseText;
           var t=setTimeout("closesharealert()",5000);

        }
    }
    self.xmlHttpReq.send(params);
}






function closesharealert(elem){
document.getElementById('shareboxinfo').innerHTML='';
document.getElementById('shareboxsubmit').innerHTML ='&nbsp;SEND ADVERT&nbsp;';
}








function doResize(){

if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape") {wW = window.innerWidth-16;}
if (navigator.appName.indexOf("Microsoft")!=-1) {  wW = document.body.offsetWidth-20; }
}
winWW= wW/80;

try{document.body.style.fontSize=winWW;}
catch(ex){alert(ex.message);}
}


function currenform(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}


function commaform(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}

/////////////Calculationsssss
////////////////////////////

function calcshowcase (value){

if(value!=0){
document.getElementById('showcaseimpressioncost').innerHTML= " ";
document.getElementById('showcaseimpressioncost').innerHTML= "&pound;"+commaform(currenform(value*0.01)) +"<br><img src=\"https://www.paypalobjects.com/WEBSCR-610-20100216-1/en_US/i/btn/x-click-but3.gif\" style=\"margin-left: 0%;cursor: pointer;width: 70%;\" border=\"0\" onclick=\"showpaypalwindow("+value+",'allscreens');\" title=\"PayPal - The safer, easier way to pay online.\" alt=\"PayPal - The safer, easier way to pay online.\">";
}else{
document.getElementById('showcaseimpressioncost').innerHTML= " ";
}

}


function calcall (value){
if(value!=0){

document.getElementById('allimpressioncost').innerHTML= " ";
document.getElementById('allimpressioncost').innerHTML= "+<input type=\"text\" id=\"prom\" name=\"\" value =\""+value*0.01+ "\"style=\"font-size: 90%;width:50%;\" >Free Prom <br>";

document.getElementById('paradeimpression').innerHTML= " &pound;"+commaform(currenform(value*0.01)) +"<br>";

}else{
///document.getElementById('allimpressioncost').innerHTML= " <input type=\"text\" name=\"bonusstarframe\" style=\"width:100%;\"> ";
}
}

function displayallprices(value){

document.getElementById('totalamounttwo').value=commaform(currenform(value*0.01));
document.getElementById('totalamounttwo').style.border="2px blue solid";
document.getElementById('buy').innerHTML="<img src=\"https://www.paypalobjects.com/WEBSCR-610-20100216-1/en_US/i/btn/x-click-but3.gif\" style=\"cursor: pointer;width: 100%;\" border=\"0\" onclick=\"showpaypalwindow2("+value+",'allscreensw',document.getElementById('prom').value);\" title=\"PayPal - The safer, easier way to pay online.\" alt=\"PayPal - The safer, easier way to pay online.\">";
document.getElementById('buy').style.display="block";
document.getElementById('agentaddressform').style.display="none";
document.getElementById('paymentbycard').checked = true;

}

function showbuy(){
document.getElementById('paymentnotice').innerHTML="";
document.getElementById('buy').style.visibility='visible';
document.getElementById('buy').style.display="block";
//document.getElementById('agentaddressform').style.visibility='hidden';
document.getElementById('agentaddressform').style.display="none";

}

function shownotice(notice){
document.getElementById('paymentnotice').innerHTML=notice;
document.getElementById('buy').style.display="none";

//document.getElementById('agentaddressform').style.visibility='visible';
document.getElementById('agentaddressform').style.display="block";
}







window.onresize = doResize;
window.onreadystate = doResize;

                       