// JavaScript Document naeem bhatt naeembhatti@gmail.com
function theDate() {
	  dat = new Date();
	  month = dat.getMonth();
	  monthname = new Array();
	  monthname[0] = "January";
	  monthname[1] = "February";
	  monthname[2] = "March";
	  monthname[3] = "April";
	  monthname[4] = "May";
	  monthname[5] = "June";
	  monthname[6] = "July";
	  monthname[7] = "August";
	  monthname[8] = "September";
	  monthname[9] = "October";
	  monthname[10] = "November";
	  monthname[11] = "December";
	  day = dat.getDate();
	  if (day == 1) {dayadd = "st";}
	  else if (day == 21) {dayadd = "st";}
	  else if (day == 31) {dayadd = "st";}
	  else if (day == 2) {dayadd = "nd";}
	  else if (day == 22) {dayadd = "nd";}
	  else if (day == 3) {dayadd = "rd";}
	  else if (day == 23) {dayadd = "rd";}
	  else {dayadd = "th";}
	  year = dat.getFullYear();
  	document.write ('<span>' + monthname[month] + ' ' + day + '<span style="font-size:9px; position:relative; top:-4px; left:1px;">' + dayadd + '</span></sup>, ' + year + '</span>');
		}
		function navOn(idName) {
			if (document.getElementById(idName)) {
				document.getElementById(idName).className="on";
			}
		}
		function navOff(idName) {
			if (document.getElementById(idName)) {
				document.getElementById(idName).className="off";
			}
		}	
//=================================		
function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
/*
var testString = '1,2,3,4,5,5';

alert('Before: ' + testString);

testString = replace(replace(testString,',','@'),',','@');

alert('After: ' + testString);*/

function showForm_through() {
if(document.getElementById){
	   document.getElementById('d_rb').innerHTML='<form action="http://newswm.bbc.co.uk/cgi-bin/change_edition.pl" name="ifhForm" method="get"><input type="hidden" name="qs" value="http://news.bbc.co.uk/1/hi/country_profiles/default.stm" /><input type="hidden" name="content" value="nol" /><input name="dest" type="radio" value="Domestic" onclick="submitForm();" id="dfh" checked /><label for="dfh" class="uk" style="font-weight:bold;">UK version</label><input name="dest" type="radio" value="International"  onclick="submitForm();"  id="ifh" /><label for="ifh" class="int">International version</label></form>';}
}
var site;
function submitForm_through() {
			document.ifhForm.submit();
}

//to remove html tags
function stripHTML(){
var re= /<\S[^><]*>/g
for (i=0; i<arguments.length; i++)
	arguments[i].value=arguments[i].value.replace(re, "")
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
//=====================================trimminggggggggggggggggggggggggggggg	
function leftTrim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	return sString;
}
function rightTrim(sString)
{
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
	sString = sString.substring(0,sString.length-1);
	}
	return sString;
}


function trimAll(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
//====================================
function show_error(str,div_id){ 
	document.getElementById(div_id).style.display = "block";
	document.getElementById(div_id).innerHTML = str;
}
function hide_error(div_id){ 

			 document.getElementById(div_id).style.display = "none";
}
//start form======================================================================================
function checkfield()
{

		var myflage=true;
		if(document.registration_form.user_name.value=='')
		{
			show_error("<font class='error'>Pleae enter your username </font>",'div_user_name');
			myflage=false;
			  
		}else{
			 check_user_name('check_user_name.php?user_name='+document.registration_form.user_name.value);
			// alert(document.registration_form.naeem.value);
			if(document.registration_form.naeem.value==1){
				myflage=false;
			}
			 // alert(newtext);
			  hide_error('div_user_name');			  
			  
		}
		
		// for email
		if(document.registration_form.txt_email.value=='')
		{
		  show_error("<font class='error'>Please enter your email.</font>",'div_email');
		  myflage=false;
		  
		}
		else if(document.registration_form.txt_email.value!='')
		{
			 if (echeck(document.registration_form.txt_email.value)==false) {
						show_error("<font class='error'>Invalid email.</font>",'div_email');
		                myflage=false;
						
			 } else {
				//  check_email('check_email.php?email='+document.registration_form.txt_email.value);
					if(document.registration_form.temp.value==1){
						myflage=false;
					}
				hide_error('div_email');			 
			 }
		}
		//for re-type email
		if((document.registration_form.txt_email.value!='')&&(document.registration_form.txt_email.value!=document.registration_form.txt_email_confirm.value)){
			show_error("<font class='error'>We’re sorry, emails do not match.</font>",'div_email_confirm');
            myflage=false;
		}else{
			hide_error('div_email_confirm');			 	
		}		
		
		//for password
		if(document.registration_form.txt_password.value==''){
			show_error("<font class='error'>Pleae enter your password.</font>",'div_password');
            myflage=false;
		}else if(document.registration_form.txt_password.value.length<6){
			show_error("<font class='error'>Passwords should be minimum of 6 characters</font>",'div_password');
            myflage=false;			
		}else{
			hide_error('div_password');			 	
		}		
		
		//agree

		 if(document.registration_form.agree.checked == false){
			 show_error("<font class='error'>Please read the Terms of Use and check the box to indicate your acceptance.</font>",'div_agree');
			 myflage=false;		
		}else{
			hide_error('div_agree');			 	
		}

		
		//if all errors true
		if(myflage==true){
		 document.registration_form.submit();
		}
	
}//end form===========================================================================================

function makeObject()
{
	var x; 
	var browser = navigator.appName; 
	//detect the client browser
	if(browser == "Microsoft Internet Explorer"){
	x = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
	x = new XMLHttpRequest();
	}
	return x;
}

//call the function makeObject()
var request = makeObject();
var new_request = makeObject();
var rate_request = makeObject();
var group_request = makeObject();
var request_interest = makeObject();
var request_linked_profile = makeObject();
var request_requested_deals = makeObject();

//function send request
function check_user_name(url){

		//document.registration_form.naeem.value=0;
		request.open('POST', url);
	
		request.onreadystatechange = function () {
		if (request.readyState == 4) {
				responsestring = request.responseText;
				var msg = responsestring.split("=");
			if (msg[1] == 'sorry') {
					//checks either user name empty or not
					if(document.registration_form.user_name.value==''){show_error("<font class='error'>Enter your username </font>",'div_user_name');}else{hide_error('div_user_name');}
					show_error('<font class="error">We’re sorry it’s already taken.</font>','msg');
					document.registration_form.naeem.value=1;
					
			}else {
					//checks either user name empty or not
					if(document.registration_form.user_name.value==''){show_error("<font class='error'>Enter your username </font>",'div_user_name');}else{hide_error('div_user_name');}						
					 hide_error('msg');
					 document.registration_form.naeem.value=0;
					 
					
			}		

		}	
	}		
	
	request.send('');
	
}
function check_email(url){

		//document.registration_form.naeem.value=0;
		request.open('POST', url);
	
		request.onreadystatechange = function () {
		if (request.readyState == 4) {
				responsestring = request.responseText;
				var msg5 = responsestring.split("=");
			if (msg5[1] == 'sorry') {
					//checks either user name empty or not
					if(document.registration_form.txt_email.value==''){show_error("<font class='error'>Enter your email </font>",'div_email');}else{hide_error('div_email');}
					show_error('<font class="error">We’re sorry it’s already taken.</font>','msg5');
					document.registration_form.temp.value=1;
					
			}else {
					//checks either user name empty or not
					if(document.registration_form.txt_email.value==''){show_error("<font class='error'>Please enter your email </font>",'div_email');}else{hide_error('div_email');}						
					 hide_error('msg5');
					 document.registration_form.temp.value=0;
					 
					
			}		

		}	
	}		
	
	request.send('');
	
}

//================================================================
//show my list
function again_call_on_add_list(){
	page='show_list.php';
	request.open('POST', page);
		request.onreadystatechange = function () {
		if (request.readyState == 4) {
				responsestring = request.responseText;
				var list = responsestring.split("=");
				var list_name=list[0];
				var list_id=list[1];
				
				 var new_list_name = list_name.split(",");
				 var new_list_id=list_id.split(",");
			//alert(list_name+'-'+list_id);
			var mystring
			
			x=document.getElementById('all_list');
			x.innerHTML='';
			x.innerHTML ="<ul class='specials'>"; 
			 for(var i=0; i<new_list_name.length;i++)
				 {
					    // mystring = new_list_name[i];
						 mystring = new_list_name[i].replace("@@@@@",",");
						 if(document.lists.add_response.value=='true'){
							 x.innerHTML += '<br/>'+'<li>&nbsp;<a href=add_response.php?list_id='+new_list_id[i]+'&req_deal_id='+document.lists.req_deal_id.value+'>'+mystring+'</a>';
						 }else if(document.lists.current_page.value=='true'){
							x.innerHTML += '<br/>'+'<li>&nbsp;<a href=organize.php?list_id='+new_list_id[i]+'>'+mystring+'</a>'; 	
						 }else if(document.lists.my_dealarmy.value=='true'){
							x.innerHTML += '<br/>'+'<li>&nbsp;<a href=my_dealarmy.php?list_id='+new_list_id[i]+'>'+mystring+'</a></li>'; 								
						}else{
							x.innerHTML += '<br/>'+'<li>&nbsp;<a href=index.php?list_id='+new_list_id[i]+'>'+mystring+'</a>'; 	
						}
						// x.innerHTML='<a href='+myAarray[i]+'>'+myAarray[i]+'</a><br>';
									
				 }
				 x.innerHTML +="</ul>";		
		}
	}		
	request.send('');
	
}
function show_add_list(div_id){ 
	
	document.lists.list_name.value='';
	document.getElementById(div_id).style.display = "block";
	document.lists.list_name.focus();
}
function hide_add_list(div_id){ 
	document.getElementById(div_id).style.display = "none";
}
function add_list(url){
	//check public or private
	var list_public;
	if(document.lists.list_public[0].checked){list_public = document.lists.list_public[0].value;
	}else{list_public = document.lists.list_public[1].value;}
	
	if(document.lists.list_name.value==''){
		document.lists.list_name.focus();
		alert('Empty List Name!');
	}else{
		page='add_list.php?list_name='+url+'&list_public='+list_public
		request.open('POST', page);
			request.onreadystatechange = function () {
			if (request.readyState == 4) {
					responsestring = request.responseText;
					var msg = responsestring.split("=");
				if (msg[1] == 'sorry') {	
						alert('error occurred please sign in to add list.');
				} else if (msg[1] == 'total_max_fiv') {
					alert('You can create upto 10 lists in total.');
					hide_add_list('show_list');
				}else{
					again_call_on_add_list();
					hide_add_list('show_list');
				}
			}
		}		
		request.send('');
	}
}
function edit_lists(){ 
	document.getElementById('edit_list_disable').style.display = "none";
	document.getElementById('edit_list_enable').style.display = "block";
	document.show_edit.list_name.focus();
}	
function edit_lists_back(){ 
	document.getElementById('edit_list_disable').style.display = "block";
	document.getElementById('edit_list_enable').style.display = "none";
	//document.show_edit.list_name.focus();
}	

function again_call_on_edit_list(request_list_id){

	page='show_heading_list.php?list_id='+request_list_id+'';
	
	new_request.open('POST', page);
		new_request.onreadystatechange = function () {
		if (new_request.readyState == 4) {
				responsestring = new_request.responseText;
				var list = responsestring.split("=");
				var list_name=list[0];
				var list_id=list[1];
				
				 var new_list_name = list_name.split(",");
				 var new_list_id=list_id.split(",");	 

				 document.getElementById('edit_list_disable').innerHTML='';
				 document.getElementById('edit_list_disable').innerHTML = '<div align="center" ><p align="left">&nbsp;&nbsp;List Name: '+new_list_name+'&nbsp;&nbsp;</p></div>';
				
				document.show_edit.list_name.value = new_list_name; // to set the latest value to edit field of list_name
			
		}
	}		
	new_request.send('');
}	


function edit_list(url,get_list_id){
	if(document.show_edit.list_name.value==''){
		document.show_edit.list_name.focus();
		alert('Empty List Name!');
	}else{
		page='edit_list.php?list_id='+get_list_id+'&list_name='+url+'';
		request.open('POST', page);
			request.onreadystatechange = function () {
			if (request.readyState == 4) {
					responsestring = request.responseText;
					var msg = responsestring.split("=");
				if (msg[1] == 'sorry') {
	
						alert('error occurred please sign in to add list');
				} else {
					
					document.show_edit.list_name.value=document.show_edit.list_name.value;
					
					again_call_on_add_list();					
					
					edit_lists_back();	
					
					//document.getElementById('edit_list_disable').innerHTML='';//empty previuse record
					
					again_call_on_edit_list(get_list_id);
					//hide_add_list('show_list');
				}
			}
		}		
		request.send('');
	}
	
}




function auto_get_list(get_list_id){
	
	page='show_heading_list.php?list_id='+get_list_id+'';
	
	new_request.open('POST', page);
	
		new_request.onreadystatechange = function () {
		if (new_request.readyState == 4) {
			
				responsestring = new_request.responseText;
				var list = responsestring.split("=");
				var list_name=list[0];
				var list_id=list[1];
				
				 var new_list_name = list_name.split(",");
				 var new_list_id=list_id.split(",");	 				 

				 document.getElementById('edit_list_disable').innerHTML = '<div align="center" ><p align="left">&nbsp;&nbsp;List Name: '+new_list_name+'&nbsp;&nbsp;</p></div>';
				// document.getElementById('naeem').innerHTML +='<input type=hidden name=temp_list_name value='+new_list_name+'>';
				 document.show_edit.list_name.value = new_list_name; // to set the latest value to edit field of list_name
				
			
		}
	}		
	new_request.send('');
}
//book marklet functions====================================================
//check the list limit max to 
function check_list_limit(){
	
	if(document.book.list_id.value=='new')
	{
		//loading image for adding list==========================================	
		document.getElementById('div_list_loading_data').style.display = "block";	
		var loadingImage = new Image();
		if(document.getElementById('list_limit_hidden_bookmark'))
		{
			loadingImage.src = "../images/loading.gif";
		}else{
			loadingImage.src = "images/loading.gif";
		}
		document.getElementById('list_loading_data').src = loadingImage.src;
		//loading image for adding list==========================================
	
	if(document.getElementById('list_limit_hidden_bookmark'))
		{
			page='../list_limit.php';
		}else{
			page='list_limit.php';
		}

	new_request.open('POST', page);
	
		new_request.onreadystatechange = function () {
		if (new_request.readyState == 4) {
			
				responsestring = new_request.responseText;
				var list = responsestring.split("=");
				var list_name=list[0];
				var list_id=list[1];				

				if(list_id=='false')
					{
						
							document.book.list_id.selectedIndex=0;
							document.getElementById('div_list_loading_data').style.display = "none";
							document.getElementById('error_list_name').style.display = "block";
							document.getElementById('error_list_name').innerHTML = '<font class=error>You can create upto 10 lists in total.</font>';			document.book.list_id.focus();	
						
							
						//document.book.list_id.value=0;		
					}else{
						document.getElementById('div_list_loading_data').style.display = "none";
						document.getElementById('div_create_new_list').style.display = "block";
						}
				//return list_id;
			}
		}		
		new_request.send('');
	}
}

function create_new_list(){
	check_list_limit()
		
	if(document.book.list_id.value!='0'){
		document.getElementById('error_list_name').style.display = "none";
		
	}
	if(document.book.list_id.value=='0'){
			document.getElementById('error_list_name').style.display = "block";
			document.getElementById('error_list_name').innerHTML = '<font class=error>Please Select List Name</font>';
			document.book.list_id.focus();	
	}
	

		if(document.book.list_id.value=='new'){
			//document.getElementById('div_create_new_list').style.display = "block";
		}else{
			document.getElementById('div_create_new_list').style.display = "none";
		}
		//requested deals===========================================

		if(document.book.list_id.value=='req_deal'){
			document.getElementById('div_requested_deals').style.display = "block";
		}else{
			document.book.requested_deal_id.value='';
			document.getElementById('div_requested_deals').style.display = "none";
			document.getElementById('error_requested_deal').style.display = "none";
		}
		//end requested deals===========================================
		//group names===========================================

		if(document.book.list_id.value=='group_name'){
			document.getElementById('div_group_name').style.display = "block";
		}else{
			document.book.group_id.value='';
			document.getElementById('div_group_name').style.display = "none";
			document.getElementById('error_group_name').style.display = "none";
		}
		//end group names===========================================
		
	}
	
//book marklet functions====================================================
function check_valid_price_click()
	{
		if(!NumericCheck(document.book.deal_price.value))
		{
			document.book.deal_price.focus();
			return false;
		}
		return true;
	}

function check_list_name(){
	
	//for ad a deal add_deal.php=====================================
	if(document.getElementById('upload_ur_img_first'))
		{
				if(document.book.deal_temp_images_name.value!='')
				{
			
					show_error("<br/>&nbsp;<font color='#FF0000'>Upload Image first!</font>",'upload_ur_img_first');		
					document.book.deal_temp_images_name.focus();
					return false;
				}else{
			
						hide_error('upload_ur_img_first');
				}
		}
	
	
	//for deal price==========================================
	if(check_valid_price_click()==true)
	{
		hide_error('show_price_error');
	}else
	{
		show_error("<font class='error' size=2>Pleae enter valid price. </font>",'show_price_error');		
		return false;
	}

	//requested deals===========================================
	if((document.getElementById('div_requested_deals').style.display=="block")&&(document.book.requested_deal_id.value==''))
	{			
			document.getElementById('error_requested_deal').style.display = "block";
			document.getElementById('error_requested_deal').innerHTML = '<font class=error>Please Select Requested Deal</font>';
			document.book.requested_deal_id.focus();
			return false;
	}else if(document.getElementById('div_requested_deals').style.display=="none")
	{

			document.getElementById('error_requested_deal').style.display = "none";
	}
	//end requested deals=======================================
	
	//group name===========================================
	if((document.getElementById('div_group_name').style.display=="block")&&(document.book.group_id.value==''))
	{			
			document.getElementById('error_group_name').style.display = "block";
			document.getElementById('error_group_name').innerHTML = '<font class=error>Please Select Group</font>';
			document.book.group_id.focus();
			return false;
	}else if(document.getElementById('div_group_name').style.display=="none")
	{

			document.getElementById('error_group_name').style.display = "none";
	}
	//end group name=======================================
	
	if(document.book.list_id.value=='0')
	{
			document.getElementById('error_list_name').style.display = "block";
			document.getElementById('error_list_name').innerHTML = '<font class=error>Please Select List Name</font>';
			document.book.list_id.focus();
			return false;
	}else
	{
		document.getElementById('error_list_name').style.display = "none";
	}

	if((document.book.list_id.value=='new')&&(document.book.list_id.value!='0')&&(document.book.new_list_name.value==''))
	{
			document.getElementById('error_list_name').style.display = "block";
			document.getElementById('error_list_name').innerHTML = '<font class=error>Please Enter List Name</font>';
			document.book.new_list_name.focus();
			return false;

	}else
	{
			document.getElementById('error_list_name').style.display = "none";
	}
	document.getElementById('hide_save_button').style.display="none";
	document.getElementById('show_saving_button').style.display="block";


}


//after adding add to different list===========================================
function get_add_different_list(){
	document.getElementById('add_different_button').style.display = "none";
	document.getElementById('show_add_list_button').style.display = "block";

}
//deals comments===========================================================
function show_my_fields(div1,div2){
	document.getElementById(div1).style.display = "block";
	document.getElementById(div2).style.display = "block";
}


//deals flags==============================================================
function send_flags(deal_id,deals_flags_id){
//	alert(deal_id+'--'+deals_flags_id);
		page='send_flags.php?deals_flags_id='+deals_flags_id+'&deal_id='+deal_id;
		request.open('POST', page);
			request.onreadystatechange = function () {
			if (request.readyState == 4) {
					responsestring = request.responseText;
					var msg = responsestring.split("=");
					
				if (msg[1] == 'sorry') {	
						alert('You have already reported about this deal.');
				} else {
					    alert('Deal has been reported.');				 
				}
			}
		}		
		request.send('');
}


//=digg show menu=========================================================
sfHover = function() { 
var sfEls = document.getElementById("dropdownnav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
	sfEls[i].onmouseover=function() {
             this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
      this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
       }
    }
}
probHover = function() { 
	var probEls = new Array()
	for (j = 0; j<100; j++) {
		probEls[j] = new Array();
		var item = document.getElementById('probdrop'+j);
		if (item) {
			probEls[j] = item.getElementsByTagName("LI");
			for (var i=0; i <probEls[j].length; i++) {
				probEls[j][i].onmouseover=function() {
			             this.className +=" probhover";
				}
				probEls[j][i].onmouseout=function() {
				          this.className=this.className.replace(new RegExp(" probhover\\b"), "");
			       }
	    		}
		}
	}
}
function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}


function checkMouseLeave (element, evt) {

  evt = (evt) ? evt : ((window.event) ? window.event : "");
  window.status = evt;
  if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  } else {
        if (element.contains(evt.toElement)) {
                return(false);
        } else {
                return(true);
        }
  }
}
function HideandUNhideObj(i){
        nav=document.getElementById('div'+i).style;
        con=document.getElementById('ul'+i);
        if(nav.display=="none"){
                // set mouseout function here
                nav.display = 'block';
                con.onmouseout = function(evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display = 'none';
                    }
                }
        } else {
                nav.display='none';
                con.onmouseout = function (evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display= 'none';
                    }
                }
        }
}

if (window.attachEvent) {
//    window.attachEvent("onload", sfHover);
    window.attachEvent("onload", probHover);
}
function HideandUNhideObj2(i){
        nav=document.getElementById('div2'+i).style;
        con=document.getElementById('ul2'+i);
        if(nav.display=="none"){
                // set mouseout function here
                nav.display = 'block';
                con.onmouseout = function(evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display = 'none';
                    }
                }
        } else {
                nav.display='none';
                con.onmouseout = function (evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display= 'none';
                    }
                }
        }
}

if (window.attachEvent) {
//    window.attachEvent("onload", sfHover);
    window.attachEvent("onload", probHover);
}
function HideandUNhideObj3(i){
        nav=document.getElementById('div3'+i).style;
        con=document.getElementById('ul3'+i);
        if(nav.display=="none"){
                // set mouseout function here
                nav.display = 'block';
                con.onmouseout = function(evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display = 'none';
                    }
                }
        } else {
                nav.display='none';
                con.onmouseout = function (evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display= 'none';
                    }
                }
        }
}

if (window.attachEvent) {
//    window.attachEvent("onload", sfHover);
    window.attachEvent("onload", probHover);
}
function HideandUNhideObjM(i){
        nav=document.getElementById('divM'+i).style;
        con=document.getElementById('ulM'+i);
        if(nav.display=="none"){
                // set mouseout function here
                nav.display = 'block';
                con.onmouseout = function(evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(3));
                        nav=document.getElementById('divM'+i).style;
                        nav.display = 'none';
                    }
                }
        } else {
                nav.display='none';
                con.onmouseout = function (evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(3));
                        nav=document.getElementById('divM'+i).style;
                        nav.display= 'none';
                    }
                }
        }
}


if (window.attachEvent) {
//    window.attachEvent("onload", sfHover);
    window.attachEvent("onload", probHover);
}
function HideandUNhideObjN(i){
        nav=document.getElementById('divN'+i).style;
        con=document.getElementById('ulN'+i);
        if(nav.display=="none"){
                // set mouseout function here
                nav.display = 'block';
                con.onmouseout = function(evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(3));
                        nav=document.getElementById('divN'+i).style;
                        nav.display = 'none';
                    }
                }
        } else {
                nav.display='none';
                con.onmouseout = function (evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(3));
                        nav=document.getElementById('divN'+i).style;
                        nav.display= 'none';
                    }
                }
        }
}


if (window.attachEvent) {
//    window.attachEvent("onload", sfHover);
    window.attachEvent("onload", probHover);
}
//user groups=============================================================
//show my groups
function again_call_on_add_group(){
	group_page='show_groups.php';
	group_request.open('POST', group_page);
		group_request.onreadystatechange = function () {
		if (group_request.readyState == 4) {
				responsestring = group_request.responseText;
				var list = responsestring.split("=");
				var list_name=list[0];
				var list_id=list[1];
				
				 var new_list_name = list_name.split(",");
				 var new_list_id=list_id.split(",");

			var mystring
			x=document.getElementById('all_groups');
			x.innerHTML = '';
			x.innerHTML ="<ul class='specials'>"; 
			 for(var i=0; i<new_list_name.length;i++)
				 {
					
						 mystring = new_list_name[i].replace("@@@@@",",");					 
						 //alert(mystring);
						 x.innerHTML += '<br/>'+'<li>&nbsp;<a href=group_detail.php?group_id='+new_list_id[i]+'>'+mystring+'</a></li>';
				 }
			 x.innerHTML +="</ul>";
		}
	}		
	group_request.send('');
	
}
function show_add_group(div_id){ 
	
	document.groups.group_name.value='';
	document.getElementById(div_id).style.display = "block";
	document.groups.group_name.focus();
}

function hide_add_group(div_id){ 
	document.getElementById(div_id).style.display = "none";
}

function add_group(url){
//	alert(url);
	if(document.groups.group_name.value==''){
		document.groups.group_name.focus();
		alert('Empty Group Name!');
	}else{
		page='add_group.php?group_name='+url+'';
		request.open('POST', page);
			request.onreadystatechange = function () {
			if (request.readyState == 4) {
					responsestring = request.responseText;
					var msg = responsestring.split("=");
				if (msg[1] == 'sorry') {	
						alert('error occurred please sign in to add list');
				} else {
					
					again_call_on_add_group();
					hide_add_group('show_group');
				}
			}
		}		
		request.send('');
	}
}

//interests=================================================
function again_call_show_all_interests(){
	page='show_interests.php';
	request.open('POST', page);
		request.onreadystatechange = function () {
		if (request.readyState == 4) {
				responsestring = request.responseText;
				var list = responsestring.split("=");
				var list_name=list[0];
				var list_id=list[1];
				
				 var new_list_name = list_name.split(",");
				 var new_list_id=list_id.split(",");

			var mystring
			
			x=document.getElementById('all_interests');
			x.innerHTML='';
			x.innerHTML ="<ul class='specials'>";
			 for(var i=0; i<new_list_name.length;i++)
				 {
					
						 mystring = new_list_name[i];
						// x.innerHTML += '<br/>'+'<a href=results.php?interest='+new_list_id[i]+'>'+mystring+'</a>';
						 x.innerHTML += '<br/>'+'<li>&nbsp;<a href=\'results.php?interest='+new_list_id[i]+'\'>'+mystring+'</a></li>';
						//   x.innerHTML += '<br/>'+mystring;
				
									
				 }
				 x.innerHTML +="</ul>";
		}
	}		
	request.send('');
	
}

function show_add_interest(div_id){ 
	
	document.interests.interest_name.value='';
	document.getElementById(div_id).style.display = "block";
	document.interests.interest_name.focus();
}
function hide_add_interest(div_id){ 
	document.getElementById(div_id).style.display = "none";
}

function add_interest(url){
	if(document.interests.interest_name.value==''){
		document.interests.interest_name.focus();
		alert('Empty Interest!');
	}else{
		page='add_interest.php?interest_name='+url
		request.open('POST', page);
			request.onreadystatechange = function () {
			if (request.readyState == 4) {
					responsestring = request.responseText;
					var msg = responsestring.split("=");
				if (msg[1] == 'sorry') {
	
						alert('error occurred please sign in to add list');
				} else {
					again_call_show_all_interests();
					hide_add_interest('show_interests');
				}
			}
		}		
		request.send('');
	}
}

//======================================
//linkded profile===================================================
function again_call_show_all_linked_profile(){
	page='show_linked_profile.php';
	request.open('POST', page);
		request.onreadystatechange = function () {
		if (request.readyState == 4) {
				responsestring = request.responseText;
				var list = responsestring.split("=");
				var list_name=list[0];
				var list_id=list[1];
				
				 var new_list_name = list_name.split(",");
				 var new_list_id=list_id.split(",");

			var mystring
			
			x=document.getElementById('all_linked_profile');
			x.innerHTML='';
			 for(var i=0; i<new_list_name.length;i++)
				 {
					
						 mystring = new_list_name[i];
						 x.innerHTML += '<br/>'+'<a href='+new_list_id[i]+'>'+mystring+'</a>';
					//	   x.innerHTML += '<br/>'+mystring;
				
									
				 }
		}
	}		
	request.send('');
	
}
function show_add_linked_profile(div_id){ 
	
	document.interests.linked_profiles_url.value='http://';
	document.getElementById(div_id).style.display = "block";
	document.interests.linked_profiles_url.focus();
}

function hide_add_linked_profile(div_id){ 
	document.getElementById(div_id).style.display = "none";
}
function checkURL(theURL){
 if (theURL.match(/http:\/\/www(\.\w+)+\.(com|org|net|[a-z]{2})$/i)==null){
  	alert('Invalid Link!');
	return false;
  }
  
}


function add_linked_profile(url){
	if(document.interests.linked_profiles_url.value==''){
		document.interests.linked_profiles_url.focus();
		alert('Empty Linked Profile!');
	}else{
		if (document.interests.linked_profiles_url.value.match(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/)==null){
				document.interests.linked_profiles_url.focus();
			  	 alert("Please enter a valid url format.\ni.e. http://www.address.com or http://address.com");
	  }else{
		  //=================
		
			page='add_linked_profile.php?linked_profiles_url='+url
			request.open('POST', page);
				request.onreadystatechange = function () {
				if (request.readyState == 4) {
						responsestring = request.responseText;
						var msg = responsestring.split("=");
					if (msg[1] == 'sorry') {
		
							alert('error occurred please sign in to add list');
					} else {
						again_call_show_all_linked_profile();
						hide_add_linked_profile('show_linked_profile');
					}
				}
			}		
			request.send('');
		}
		//============================
	}
	
}

//end linked profile================================================
//save deal
function save_deal(deal_id){

				
//alert(deal_id);
		request.open('POST', '../edit_deal.php?deal_id='+deal_id);
	
		request.onreadystatechange = function () {
		if (request.readyState == 4) {
				responsestring = request.responseText;
				var msg5 = responsestring.split("=");
			if (msg5[1] == 'sorry') {
				alert('sorry session expired try again.');
					
			}else {
				//alert('A');
					setTimeout('self.close();',3000);	 				 
				 //alert('B');
			}		

		}	
	}		
	
	request.send('');
	

}
//==============================================================
//save my deal
function save_deal_to_list(deal_id,list_id){
//	alert(deal_id+'--'+deals_flags_id);
		if(document.getElementById('dumy_hidden_bookmark'))
		{
			page='../../save_deal_to_list.php?list_id='+list_id+'&deal_id='+deal_id;
		}else{
			page='save_deal_to_list.php?list_id='+list_id+'&deal_id='+deal_id;
		}
		request.open('POST', page);
			request.onreadystatechange = function () {
			if (request.readyState == 4) {
					responsestring = request.responseText;
					var msg = responsestring.split("=");
					
				if (msg[1] == 'sorry') {	
						alert('Deal is already in your list.');
				} else {
					    alert('Deal has been saved to your list.');				 
				}
			}
		}		
		request.send('');
}

//open pop up==============================================
function open_window(page){
	 window.open (page, "dealarmy", "location=0,status=1,menubar=no,resizable=yes,scrollbars=1");
	}
	

function open_window_block(page){
	 window.open (page, "dealarmy");
	}
function mail(subject)
   {
  
      location="mailto:dealarmy@gmail.com?subject="+subject;
      return true;
   }
   
	var win = null;
	function open_window_terms(mypage,myname,w,h,scroll)
	{
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings =
		'width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
		win = window.open(mypage,myname,settings)
	}
//=merchant==========================================================
//function send request
function check_compnay_name(url){

		//document.registration_form.naeem.value=0;
		request.open('POST', url);
	
		request.onreadystatechange = function () {
		if (request.readyState == 4) 
		{
				responsestring = request.responseText;
				var msg = responsestring.split("=");
			if (msg[1] == 'sorry') 
			{
					//checks either user name empty or not
					if(document.registration_form.compnay_name.value==''){show_error("<font class='error'>Please enter your compnay name </font>",'div_compnay_name');}else{hide_error('div_compnay_name');}
					show_error('<font class="error">We’re sorry it’s already taken.</font>','msg');
					document.registration_form.naeem.value=1;
					
			}else {
					//checks either user name empty or not
					if(document.registration_form.compnay_name.value==''){show_error("<font class='error'>Please enter your compnay name </font>",'div_compnay_name');}else{hide_error('div_compnay_name');}						
					 hide_error('msg');
					 document.registration_form.naeem.value=0;
			}		

		}	
	}		
	
	request.send('');
	
}

function check_merchant_email(url){

		//document.registration_form.naeem.value=0;
		request.open('POST', url);
	
		request.onreadystatechange = function () {
		if (request.readyState == 4) {
				responsestring = request.responseText;
				var msg5 = responsestring.split("=");
			if (msg5[1] == 'sorry') {
					//checks either user name empty or not
					if(document.registration_form.merchant_email.value==''){show_error("<font class='error'>Enter your email </font>",'div_email');}else{hide_error('div_email');}
					show_error('<font class="error">We’re sorry it’s already taken.</font>','msg5');
					document.registration_form.temp.value=1;
					
			}else {
					//checks either user name empty or not
					if(document.registration_form.merchant_email.value==''){show_error("<font class='error'>Please enter your email </font>",'div_email');}else{hide_error('div_email');}						
					 hide_error('msg5');
					 document.registration_form.temp.value=0;
					 
					
			}		

		}	
	}		
	
	request.send('');
	
}
//start form======================================================================================
function checkfield_merchant()
{

		var myflage=true;
		if(document.registration_form.compnay_name.value=='')
		{
			show_error("<font class='error'>Please enter your compnay name </font>",'div_compnay_name');
			myflage=false;
			  
		}else{
			 check_compnay_name('check_compnay_name.php?compnay_name='+document.registration_form.compnay_name.value);
			// alert(document.registration_form.naeem.value);
			if(document.registration_form.naeem.value==1){
				myflage=false;
			}
			 // alert(newtext);
			  hide_error('div_compnay_name');			  
			  
		}
		
		// for email
		if(document.registration_form.merchant_email.value=='')
		{
		  show_error("<font class='error'>Please enter your email.</font>",'div_email');
		  myflage=false;
		  
		}
		else if(document.registration_form.merchant_email.value!='')
		{
			 if (echeck(document.registration_form.merchant_email.value)==false) {
						show_error("<font class='error'>Invalid email.</font>",'div_email');
		                myflage=false;
						
			 } else {
				//  check_email('check_email.php?email='+document.registration_form.txt_email.value);
					if(document.registration_form.temp.value==1){
						myflage=false;
					}
				hide_error('div_email');			 
			 }
		}
		//for re-type email
		if((document.registration_form.merchant_email.value!='')&&(document.registration_form.merchant_email.value!=document.registration_form.txt_email_confirm.value)){
			show_error("<font class='error'>We’re sorry, emails do not match.</font>",'div_email_confirm');
            myflage=false;
		}else{
			hide_error('div_email_confirm');			 	
		}		
		
		//for password
		if(document.registration_form.txt_password.value==''){
			show_error("<font class='error'>Pleae enter your password.</font>",'div_password');
            myflage=false;
		}else if(document.registration_form.txt_password.value.length<6){
			show_error("<font class='error'>Passwords should be minimum of 6 characters</font>",'div_password');
            myflage=false;			
		}else{
			hide_error('div_password');			 	
		}		
		
		//agree

		 if(document.registration_form.agree.checked == false){
			 show_error("<font class='error'>Please read the Terms of Use and check the box to indicate your acceptance.</font>",'div_agree');
			 myflage=false;		
		}else{
			hide_error('div_agree');			 	
		}

		
		//if all errors true
		if(myflage==true){
		 document.registration_form.submit();
		}
	
}//end form===========================================================================================

//end merchant=======================================================

//user power deals sige me up starts=================================
function sign_me_up(power_deal_id){
			window.location="m_power_sign_up.php?power_deal_id="+power_deal_id;
	}
function sign_me_up_merchant(merchant_power_deal_id){
			window.location="m_merchant_sign_up.php?merchant_power_deal_id="+merchant_power_deal_id;
	}
	
	
//function category_change(page,cat_id){
	//alert('fdfdf');
			//window.location=""+page+"?cat_id="+cat_id;
//	}

//user power deals sige me up ends=================================


//==============================================================
//save my power deal
function save_power_deal_to_list(power_deal_id,list_id){
//	alert(deal_id+'--'+deals_flags_id);
		page='save_power_deal_to_list.php?list_id='+list_id+'&power_deal_id='+power_deal_id;
		request.open('POST', page);
			request.onreadystatechange = function () {
			if (request.readyState == 4) {
					responsestring = request.responseText;
					var msg = responsestring.split("=");
					
				if (msg[1] == 'sorry') {	
						alert('Power Deal is already in your list.');
				} else {
					    alert('Power Deal has been saved to your list.');				 
				}
			}
		}		
		request.send('');
}


//==============================================================
//save my merchant _ replied deal 
function save_merchant_deal(merchant_power_deal_id,list_id){
//	alert(deal_id+'--'+deals_flags_id);
		page='save_merchant_deal.php?list_id='+list_id+'&merchant_power_deal_id='+merchant_power_deal_id;
		request.open('POST', page);
			request.onreadystatechange = function () {
			if (request.readyState == 4) {
					responsestring = request.responseText;
					var msg = responsestring.split("=");
					
				if (msg[1] == 'sorry') {	
						alert('Deal is already in your list.');
				} else {
					    alert('Deal has been saved to your list.');				 
				}
			}
		}		
		request.send('');
}

//==============================================
//merchant sign me up
function merchant_sign_up(merchant_power_deal_id){
			window.location="merchant_deal_detail.php?merchant_power_deal_id="+merchant_power_deal_id;
	}

//add new deal in site====================================================
function add_deal_in_site(){
	
	//requested deals===========================================
	if((document.getElementById('div_requested_deals').style.display=="block")&&(document.book.requested_deal_id.value=='')){			
			document.getElementById('error_requested_deal').style.display = "block";
			document.getElementById('error_requested_deal').innerHTML = '<font class=error>Please Select Requested Deal</font>';
			document.book.requested_deal_id.focus();
			return false;
	}else if(document.getElementById('div_requested_deals').style.display=="none"){

			document.getElementById('error_requested_deal').style.display = "none";
	}
	//end requested deals=======================================
	
	//group name===========================================
	if((document.getElementById('div_group_name').style.display=="block")&&(document.book.group_id.value=='')){			
			document.getElementById('error_group_name').style.display = "block";
			document.getElementById('error_group_name').innerHTML = '<font class=error>Please Select Group</font>';
			document.book.group_id.focus();
			return false;
	}else if(document.getElementById('div_group_name').style.display=="none"){

			document.getElementById('error_group_name').style.display = "none";
	}
	//end group name=======================================
	
	if(document.book.list_id.value=='0'){
			document.getElementById('error_list_name').style.display = "block";
			document.getElementById('error_list_name').innerHTML = '<font class=error>Please Select List Name</font>';
			document.book.list_id.focus();
			return false;
	}else{
		document.getElementById('error_list_name').style.display = "none";
	}

	if((document.book.list_id.value=='new')&&(document.book.list_id.value!='0')&&(document.book.new_list_name.value=='')){
			document.getElementById('error_list_name').style.display = "block";
			document.getElementById('error_list_name').innerHTML = '<font class=error>Please Enter List Name</font>';
			document.book.new_list_name.focus();
			return false;

		}else{
			document.getElementById('error_list_name').style.display = "none";
	}
	
	if(document.book.deal_temp_images_name.value!='')
	{	
			show_error("<font class='error'>Upload Image first! </font>",'show_error_temp_image');
			return false;
	}

}

//add your tags============================================================================
//show my list

function show_tags(deal_id){
	page='show_tags.php?deal_id='+deal_id;
	request.open('POST', page);
		request.onreadystatechange = function () {
		if (request.readyState == 4) {
				responsestring = request.responseText;
				var new_list_name = responsestring.split(",");
				
			var mystring
			x=document.getElementById('show_tags');
			document.getElementById('show_tags').style.display = "block";
			x.innerHTML='';
			x.innerHTML ='<span><strong>Tags:</strong></span> ';
			//var for_text_box_value='';
			 for(var i=1; i<new_list_name.length;i++)
				 {
							 mystring = new_list_name[i];							 
							 x.innerHTML +='<a href="results.php?interest='+leftTrim(mystring)+'">'+mystring+'</a>,  ';
 							// for_text_box_value += leftTrim(mystring)+', ';
									
				 }
				// document.frm.edit_deal_tags_name.value = trimAll(for_text_box_value);
		}
	}		
	request.send('');
	
}
function show_tags_true()
	{
		if(document.getElementById('show_tags_true').style.display=="none")
		{
			document.getElementById('show_tags_true').style.display = "block";
			document.getElementById('show_user_tags').style.display = "block";
			document.frm.edit_deal_tags_name.focus();
			
			//document.getElementById('show_tags').style.display = "none";
		}else
		{
			document.getElementById('show_tags_true').style.display = "none";
			document.getElementById('show_user_tags').style.display = "none";
			document.getElementById('show_tags').style.display = "block";

		}
		
	}
function add_tags(deal_id){
//	 alert(document.frm.edit_deal_tags_name.value);
	if(document.frm.edit_deal_tags_name.value=='')
	{
		alert('Empty Tag!');
		document.frm.edit_deal_tags_name.focus();
	}else{
	
		page='add_tags.php?deal_id='+deal_id+'&deals_tags_by_user_name='+document.frm.edit_deal_tags_name.value+'';
		request.open('POST', page);
		request.onreadystatechange = function () {
		if (request.readyState == 4) 
			{
				show_user_tags(deal_id);
				show_tags(deal_id);
				document.frm.edit_deal_tags_name.value='';
				document.getElementById('show_tags_true').style.display = "none";
				document.getElementById('show_user_tags').style.display = "none";
			}
		}
		request.send('');
	}
	
	//document.getElementById('show_tags').style.display = "none";
	//show_tags(deal_id);
}
function delete_my_tag(deals_tags_by_user_id,deal_id)
	{
			
		page='delete_tags.php?deals_tags_by_user_id='+deals_tags_by_user_id;
		request.open('POST', page);
		request.onreadystatechange = function () {
		if (request.readyState == 4) 
			{
				//document.getElementById('show_user_tags').innerHTML='';//empty previuse record
				show_user_tags(deal_id);
				show_tags(deal_id);
				//document.frm.edit_deal_tags_name.value='';
				
				//document.getElementById('show_user_tags').style.display = "none";
			}
		}
		request.send('');
	}

function show_user_tags(deal_id){
	page1='show_user_tags.php?deal_id='+deal_id;
	new_request.open('POST', page1);
		new_request.onreadystatechange = function () {
		if (new_request.readyState == 4) {
				responsestring = new_request.responseText;
				var list = responsestring.split("=+=");
				var list_name=list[0];
				var list_id=list[1];
				
				 var new_list_name = list_name.split(",");
				 var new_list_id=list_id.split(",");
			document.getElementById('show_user_tags').innerHTML='';//empty previuse record				 
			if(list_id!='empty_error')
			{
				var mystring
				
				x=document.getElementById('show_user_tags');
				//document.getElementById('show_user_tags').innerHTML='';//empty previuse record
				 for(var i=0; i<new_list_name.length;i++)
					 {
								mystring = replace(replace(new_list_name[i],',','@@@@@'),'@@@@@',',');
								x.innerHTML +='<br/><a href="results.php?interest='+leftTrim(mystring)+'">'+mystring+'</a>';
								x.innerHTML +=' <a href="javascript://" title="Delete this tag?" onclick="delete_my_tag('+new_list_id[i]+','+deal_id+')">[x]</a>';
							// x.innerHTML='<a href='+myAarray[i]+'>'+myAarray[i]+'</a><br>';
							 
	
										
					 }
			}
		}
	}		
	new_request.send('');
	
}
function delete_edit_tag(deals_tags_by_user_id,deal_id)
	{
			
		page='delete_tags.php?deals_tags_by_user_id='+deals_tags_by_user_id;
		request.open('POST', page);
		request.onreadystatechange = function () {
		if (request.readyState == 4) 
			{

				show_edit_user_tags(deal_id);

			}
		}
		request.send('');
	}

function show_edit_user_tags(deal_id){
	page1='show_edit_user_tags.php?deal_id='+deal_id;
	new_request.open('POST', page1);
		new_request.onreadystatechange = function () {
		if (new_request.readyState == 4) {
				responsestring = new_request.responseText;
				
				var list = responsestring.split("=+=");
				var list_name=list[0];
				var list_id=list[1];
				
				 var new_list_name = list_name.split(",");
				 var new_list_id=list_id.split(",");
			//alert(list_name+'-'+list_id);
			document.getElementById('show_edit_user_tags').innerHTML='';//empty previuse record
			if(list_id!='empty_error')
			{
				var mystring
				
				x=document.getElementById('show_edit_user_tags');
				//document.getElementById('show_edit_user_tags').innerHTML='';//empty previuse record
				x.innerHTML ='<b>User Added Tags</b><br/>';
				
				 for(var i=0; i<new_list_name.length;i++)
					 {
						 
								mystring = replace(replace(new_list_name[i],',','@@@@@'),'@@@@@',',');
								x.innerHTML +='<br/><a href="results.php?interest='+leftTrim(mystring)+'">'+mystring+'</a>';
								x.innerHTML +=' <a href="javascript://" title="Delete this tag?" onclick="delete_edit_tag('+new_list_id[i]+','+deal_id+')">[x]</a>';
										
					 }
			}
			
		}
	}		
	new_request.send('');
	
}
function change_price_in_name()
	{
				var el = document.getElementById('deal_price_in');	
				var e2 = document.getElementById('deal_price_in_1');				
				var e3 = document.getElementById('div_deal_price_in');
				
				if(el.value=='add_currency'){
						e3.style.display = "block";
						e2.setAttribute('name','deal_price_in');
						el.setAttribute('name','dumy_not_need');												
						
				}else{
						e3.style.display = "none";	
						e2.setAttribute('name','dumy_not_need');
						el.setAttribute('name','deal_price_in');												
				}
				
	}
//end tags=========================================================================================
function NumericCheck(fl)
 {
   var checkOK = "0123456789.";
   var checkStr;
   var allValid;
   var decPoints;
   var allNum;

   checkStr = fl
   allValid = true;
   decPoints = 0;
   allNum = "";

   for (k = 0;  k < checkStr.length;  k++)
   {
    ch = checkStr.charAt(k);
    for (l = 0;  l < checkOK.length;  l++)
      if (ch == checkOK.charAt(l)) break;
      if (l == checkOK.length)
      {
        allValid = false;
        break;
      }
      if (ch != ",") allNum += ch;
    }

   if (!allValid)
   {
  //  alert("Please enter only digit characters in the \"Numeric\" field.");
    return (false);
   }
   
   return (true);
}