var req = null;
function InitXMLHttpRequest() {
	// Make a new XMLHttp object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
//	if (typeof window.ActiveXObject != 'undefined' ) req = new ActiveXObject("Microsoft.XMLHTTP");
//	else req = new XMLHttpRequest();
}
// Added By SM :

//
function getage(str)
{
   
   
  var user = document.getElementById("txtlogin").value;
  var breeder = document.getElementById("brdrname").value;
  //breeder = breeder.split(':');
  //alert(breeder[0]);
  destination = document.getElementById('txtHint');
  InitXMLHttpRequest();
	// Load the result from the response page
  if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				destination.innerHTML = req.responseText;
			} else {
				destination.innerHTML = "Loading data...";
			}
		}
		req.open("GET", "reg_logic.php?sel=age&age="+str+"&user="+user+"&brdr="+breeder, true);
		                       
		req.send(null);
   } else {
	  destination.innerHTML = 'Browser unable to create XMLHttp Object';
  }      
  	
	
}
function buy(str)
{
  //alert(str);
  var user = document.getElementById("txtlogin3").value;
  if(user == '')
  {
	  user =   document.getElementById("txtlogin").value;
	  }
  destination = document.getElementById('txtHint');
  InitXMLHttpRequest();
	// Load the result from the response page
  
  if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				destination.innerHTML = req.responseText;
			} else {
				destination.innerHTML = "Loading data...";
			}
		}
		req.open("GET", "reg_logic.php?sel=act&act="+str+"&user="+user, true);
		                      
		req.send(null);
   } else {
	  destination.innerHTML = 'Browser unable to create XMLHttp Object';
  }      
  
  
}
 
function showHint(str)
{
  
  var t = document.profile.brdy;
  var brdr = 0;
  for(i=0;i<t.length;i++)
  {
	  if(t[i].value == 1 && t[i].checked == true)
	  {
	     brdr = 1;
		 
	  }
	  if(t[i].value == 0 && t[i].checked == true)
	  {
	     brdr = 0;
		 
	  }
	  
  }
  //alert(brdr);
  destination = document.getElementById('txtHint');
  InitXMLHttpRequest();
	// Load the result from the response page
  if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				destination.innerHTML = req.responseText;
			} else {
				destination.innerHTML = "Loading data...";
			}
		}
		req.open("GET", "reg_logic.php?sel=user&user="+str+"&brdr="+brdr, true);
		req.send(null);
		//a/lert(destination.innerHTML);
   } else {
	  destination.innerHTML = 'Browser unable to create XMLHttp Object';
  }      
   
}
// functions for reg_log file : 
function sub_brdr_form_puppy()
{
   var newbrdrname = document.getElementById("newbrdrname").value;
   var newbrdradd = document.getElementById("newbrdradd").value;
   var newbrdremail = document.getElementById("newbrdremail").value;
   var brdr_brdr = document.getElementById("brdr_brdr").value;
   var brdr_user = document.getElementById("brdr_user").value;
    
   	
   destination = document.getElementById('txtHint');
   InitXMLHttpRequest();
   
   if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				destination.innerHTML = req.responseText;
			} else {
				destination.innerHTML = "Loading data...";
			}
		}
		req.open("GET", "reg_logic.php?sel=processpuppy&unm="+brdr_user+"&brd="+brdr_brdr+"&nbn="+newbrdrname+"&nadd="+newbrdradd+"&nem="+newbrdremail, true);
		req.send(null);
   } else {
	  destination.innerHTML = 'Browser unable to create XMLHttp Object';
   }
   
}
function sub_brdr_form_adult()
{
   var newbrdrname = document.getElementById("newbrdrname").value;
   var newbrdradd = document.getElementById("newbrdradd").value;
   var newbrdremail = document.getElementById("newbrdremail").value;
   var brdr_brdr = document.getElementById("brdr_brdr").value;
   var brdr_user = document.getElementById("brdr_user").value;
    
   	
   destination = document.getElementById('txtHint');
   InitXMLHttpRequest();
   
   if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				destination.innerHTML = req.responseText;
			} else {
				destination.innerHTML = "Loading data...";
			}
		}
		req.open("GET", "reg_logic.php?sel=processadult&unm="+brdr_user+"&brd="+brdr_brdr+"&nbn="+newbrdrname+"&nadd="+newbrdradd+"&nem="+newbrdremail, true);
		req.send(null);
   } else {
	  destination.innerHTML = 'Browser unable to create XMLHttp Object';
   }
   
}
function sub_brdr_form()
{
  
   var newbrdrname = document.getElementById("newbrdrname").value;
   var newbrdradd = document.getElementById("newbrdradd").value;
   var newbrdremail = document.getElementById("newbrdremail").value;
   var brdr_brdr = document.getElementById("brdr_brdr").value;
   var brdr_user = document.getElementById("brdr_user").value;
    
   //alert(newbrdrname+newbrdradd+newbrdremail);	
   destination = document.getElementById('txtHint');
   InitXMLHttpRequest();
   //alert("reg_logic.php?sel=process&unm="+brdr_user+"&brd="+brdr_brdr+"&nbn="+newbrdrname+"&nadd="+newbrdradd+"&nem="+newbrdremail);
   if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				destination.innerHTML = req.responseText;
			} else {
				destination.innerHTML = "Loading data...";
			}
		}
		req.open("GET", "reg_logic.php?sel=process&unm="+brdr_user+"&brd="+brdr_brdr+"&nbn="+newbrdrname+"&nadd="+newbrdradd+"&nem="+newbrdremail, true);
		req.send(null);
   } else {
	  destination.innerHTML = 'Browser unable to create XMLHttp Object';
   }
   
}
// end of reg_logic file 
function SelectBreeder_from_mother(section, id_country, destination, destination2) {
	
	if (id_country != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					if (section == 'rp') {
						destination.innerHTML = "<select style=\"width:150px\"><option>Loading data...</option></select>";
					} else {
						destination.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>Loading data...</option></select>";
					}
				}
			}
			req.open("GET", "brdr.php?sec=" + section + "&sel=breeder_mother&id_country=" + id_country, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}
	} else {
		destination.innerHTML = "Country is not selected";
	}
	if (section == 'as') {
		destination2.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>All</option></select>";
	} else {
		if (section == 'rp') {
			destination2.innerHTML = "<select style=\"width:150px\"><option>Please select...</option></select>";
		} else {
			destination2.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>Please select...</option></select>";
		}

	}
} 
function Selectfamily_mother(section, id_region, destination,id_country) {
	
	if (id_region != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					if (section == 'rp') {
						destination.innerHTML = "<select style=\"width:150px\"><option>Loading data...</option></select>";
					} else {
						destination.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>Loading data...</option></select>";
					}
				}
			}
			//alert("brdr.php?sec=" + section + "&sel=family&id_region=" + id_region + "&id_country=" + id_country);
			req.open("GET", "brdr.php?sec=" + section + "&sel=family_mother&id_region=" + id_region + "&id_country=" + id_country, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}
	} else {
		destination.innerHTML = "Region is not selected";
	}
	
}
// end code : 
// Added By Kaushik ....
function SelectBreeder(section, id_country, destination, destination2) {
	
	if (id_country != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					if (section == 'rp') {
						destination.innerHTML = "<select style=\"width:150px\"><option>Loading data...</option></select>";
					} else {
						destination.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>Loading data...</option></select>";
					}
				}
			}
			req.open("GET", "brdr.php?sec=" + section + "&sel=region&id_country=" + id_country, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}
	} else {
		destination.innerHTML = "Country is not selected";
	}
	if (section == 'as') {
		destination2.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>All</option></select>";
	} else {
		if (section == 'rp') {
			destination2.innerHTML = "<select style=\"width:150px\"><option>Please select...</option></select>";
		} else {
			destination2.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>Please select...</option></select>";
		}

	}
}

// Added By Kaushik ....
function Selectfamily(section, id_region, destination,id_country) {
	document.getElementById('brdrname').value=id_region;
	if (id_region != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					if (section == 'rp') {
						destination.innerHTML = "<select style=\"width:150px\"><option>Loading data...</option></select>";
					} else {
						destination.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>Loading data...</option></select>";
					}
				}
			}
			//alert("brdr.php?sec=" + section + "&sel=family&id_region=" + id_region + "&id_country=" + id_country);
			req.open("GET", "brdr.php?sec=" + section + "&sel=family&id_region=" + id_region + "&id_country=" + id_country, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}
	} else {
		destination.innerHTML = "Region is not selected";
	}
	
}

function SelectCountry(section, destination) {
	//alert('this is select country table');
	var t = eval(destination.innerHTML);
	//alert(destination);
	InitXMLHttpRequest();
	// Load the result from the response page
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				destination.innerHTML = req.responseText;
			} else {
				if (section == 'rp') {
					destination.innerHTML = "<select style=\"width:150px\"><option>Loading data...</option></select>";
				} else {
					destination.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>Loading data...</option></select>";
				}

			}
		}
		req.open("GET", "location.php?sec=" + section + "&sel=country", true);
		req.send(null);
	} else {
		destination.innerHTML = 'Browser unable to create XMLHttp Object';
	}
}

function SelectRegion(section, id_country, destination, destination2) {
	//alert('asdfsd');
	
	if (id_country != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					if (section == 'rp') {
						destination.innerHTML = "<select style=\"width:150px\"><option>Loading data...</option></select>";
					} else {
						destination.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>Loading data...</option></select>";
					}
				}
			}
			req.open("GET", "location.php?sec=" + section + "&sel=region&id_country=" + id_country, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}
	} else {
		destination.innerHTML = "Country is not selected";
	}
	if (section == 'as') {
		destination2.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>All</option></select>";
	} else {
		if (section == 'rp') {
			destination2.innerHTML = "<select style=\"width:150px\"><option>Please select...</option></select>";
		} else {
			destination2.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>Please select...</option></select>";
		}

	}
}
// Added By SM :
function showdog(d)
{
   var ull = "breeder_search.php?act=dog&brdid=" + d;
   document.getElementById('countrybox').innerHTML='';
   document.getElementById('breeder').innerHTML='<table id="brdtable" style="display:none;"><thead><tr><th>SNo.</th><th>Breeder Name</th><th>Family Name</th><th>Location</th><th>Male Dog</th><th>Female Dog</th><th>Puppy</th><th>Alive Dog</th><th>Total Dog</th></tr></thead><tbody><tr><td>static col 1</td><td>static col 2</td></tbody></table>';
     // document.getElementById('master1').innerHTML='';
					var mygrid7 = $("#dog_table").ingrid({ 
										url: ull,
										height: 300,
										savedStateLoad: true,
										colWidths: [100,450],
										resizableCols: false,
										paging: false,
										sorting : false,
										rowClasses: ['grid-row-style1','grid-row-style2'],
										onRowSelect: function(tr, selected){											
											var str 		= selected ? 'SELECTED' : 'UNSELECTED';
											var tr_html	= $(tr).html();											
											//alert( str + ' Row. HTML is : ' + tr_html);	
											//alert("Send to other page");
										}										
									});
}
function showpuppy(d,type)
{
   var ull = "puppies_search.php?act=puppylist&brdid="+d+"&show="+type;
   document.getElementById('doglist').innerHTML='<table id="dogtable" style="display:none;"><thead><tr><th>SNo.</th><th>Breeder Name</th><th>Family Name</th><th>Location</th><th>Male Dog</th><th>Female Dog</th><th>Puppy</th><th>Alive Dog</th><th>Total Dog</th></tr></thead><tbody><tr><td>static col 1</td><td>static col 2</td></tbody></table>';
					var mygrid7 = $("#puppytable").ingrid({ 
										url: ull,
										height: 300,
										savedStateLoad: true,
										colWidths: [100,450],
										resizableCols: false,
										paging: false,
										sorting : false,
										rowClasses: ['grid-row-style1','grid-row-style2'],
										onRowSelect: function(tr, selected){											
											var str 		= selected ? 'SELECTED' : 'UNSELECTED';
											var tr_html	= $(tr).html();											
										}										
									});
}
function showbreederlist(d,country,region,city){
	var ull = "puppies_search.php?act=doglist&brdid="+d+"&cnt="+country+"&reg="+region+"&city="+city;
   document.getElementById('countrybox').innerHTML='<a href="puppies_search.php">Back to Puppy Search</a>';
   document.getElementById('breeder').innerHTML='<table id="brdtable" style="display:none;"><thead><tr><th>SNo.</th><th>Breeder Name</th><th>Family Name</th><th>Location</th><th>Male Dog</th><th>Female Dog</th><th>Puppy</th><th>Alive Dog</th><th>Total Dog</th></tr></thead></table>';
     // document.getElementById('master1').innerHTML='';
					var mygrid7 = $("#dogtable").ingrid({ 
										url: ull,
										height: 300,
										initialLoad: true,
										paging: false,
										sorting : false,
										totalRecords: 1000,
										recordsPerPage:50,
										resizableCols: false,
										colWidths: [30,150,150,180,80,80,80,80,80],
										rowClasses: ['grid-row-style1','grid-row-style2'],
										onRowSelect: function(tr, selected){											
											var str 		= selected ? 'SELECTED' : 'UNSELECTED';
											var tr_html	= $(tr).html();											
											//alert( str + ' Row. HTML is : ' + tr_html);	
											//alert("Click On Name of Pupply");
										}										
									});
}
// Added By AG
function showpuppies(d)
{
   destination.innerHTML = '';
   //alert(d);
   var aj = "puppies_search.php?sel=dog&brdid=" + d;
   //alert(aj);
   
  
   destination = document.getElementById('dog_div');
	
	if (d != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				
				
				if (req.readyState == 4) {
					var mygrid1 = $("#table1").ingrid({ 
										url: aj,
										height: 100,
										savedStateLoad: true,
										rowClasses: ['grid-row-style1','grid-row-style2'],
										onRowSelect: function(tr, selected){											
											var str 		= selected ? 'SELECTED' : 'UNSELECTED';
											var tr_html	= $(tr).html();											
											//alert( str + ' Row. HTML is : ' + tr_html);	
											alert("Send to other page");
										}										
									});
					var sh = 'show';
					destination.innerHTML = req.responseText;
				} else {
					destination.innerHTML = "Loading data...";
				}
			}
			
			req.open("GET", aj, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}        
	} else {
		destination.innerHTML = "Breeder is not selected";
	}
	
}

function SelectRegion1(id_country, destination, destination2) {
//    document.getElementById('dog_div').innerHTML = ''; 
//alert(destination);
	if (id_country != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					destination.innerHTML = "Loading data...";
				}
			}
			req.open("GET", "admin/admin_location.php?sel=regionfront&id_country=" + id_country, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}        
	} else {
		destination.innerHTML = "Country is not selected";
	}
	destination2.innerHTML = "";
}
// by ag
function SelectRegion2(id_country, destination, destination2) {
    //document.getElementById('dog_div').innerHTML = ''; 
	if (id_country != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					destination.innerHTML = "Loading data...";
				}
			}
			req.open("GET", "admin/admin_location.php?sel=regionfront2&id_country=" + id_country, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}        
	} else {
		destination.innerHTML = "Country is not selected";
	}
	destination2.innerHTML = "";
}

function SelectCity(section,id_region, destination) {
	
	// Remove this comment if profile not working(but front city wont work) : document.getElementById('region').value=id_region;
	
	if(destination == 'city_div')
	{
		destination = document.getElementById('city_div');
	}
	if (id_region != '') {
		
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					destination.innerHTML = "Loading data...";
				}
			}
			
			req.open("GET", "admin/admin_location.php?sel=city&id_region=" + id_region, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}        
	} else {
		destination.innerHTML = "Region is not selected";
	}
}
// by ag
function SelectCity2(id_region, destination) {
	
	document.getElementById('region').value=id_region;
	if(destination == 'city_div')
	{
		destination = document.getElementById('city_div');
	}
	if (id_region != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					destination.innerHTML = "Loading data...";
				}
			}
			req.open("GET", "admin/admin_location.php?sel=city&id_region=" + id_region, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}        
	} else {
		destination.innerHTML = "Region is not selected";
	}
}

function SelectCityFront(id_region, destination)
{
     document.getElementById('region').value=id_region;
	if(destination == 'city_div')
	{
		destination = document.getElementById('city_div');
	}
	if (id_region != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					destination.innerHTML = "Loading data...";
				}
			}
			req.open("GET", "admin/admin_location.php?sel=cityFront&id_region=" + id_region, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}        
	} else {
		destination.innerHTML = "Region is not selected";
	}  	
}
// by ag
function SelectCityFront2(id_region, destination)
{

	document.getElementById('region').value=id_region;
	if(destination == 'city_div1')
	{
		destination = document.getElementById('city_div1');
	}
	if (id_region != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					destination.innerHTML = "Loading data...";
				}
			}
			req.open("GET", "admin/admin_location.php?sel=cityFront2&id_region=" + id_region, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}        
	} else {
		destination.innerHTML = "Region is not selected";
	}  	
}

function getbreeder(vat)
{
  // alert('this is for breeder page: ');
   var city = vat;
   var region =  document.getElementById('region').value;
   var country = document.getElementById('country').value; 
   var id_region = 1;
   var ul = "breeder_search.php?act=breeder&cnt="+country+"&reg="+region+"&city="+city;	
   document.getElementById('breeder').innerHTML='<table id="brdtable" style="display:none;"><thead><tr><th>SNo.</th><th>Breeder Name</th><th>Family Name</th><th>Location</th><th>Male Dog</th><th>Female Dog</th><th>Puppy</th><th>Alive Dog</th><th>Total Dog</th></tr></thead><tbody><tr><td>static col 1</td><td>static col 2</td><td>static col 3</td><td>static col 4</td><td>static col 5</td><td>static col 6</td><td>static col 7</td><td>static col 8</td><td>static col 9</td></tr></tbody></table>';
	var mygrid4 = $("#brdtable").ingrid({ 
										url: ul,
										height: 100,
										initialLoad: true,
										paging: false,
										sorting : false,
										totalRecords: 1000,
										recordsPerPage:50,
										resizableCols: false,
										colWidths: [30,150,150,180,80,80,80,80,80],
										tablename:'master',
										rowClasses: ['grid-row-style1','grid-row-style2'],
										onRowSelect: function(tr, selected){											
											var str 		= selected ? 'SELECTED' : 'UNSELECTED';
											var tr_html	= $(tr).html();											
										}										
									});
}
// by ag
function getbreeder1(vat)
{
  //alert('this is city function to get breeder');
   var city = vat;
   var region =  document.getElementById('region').value;
   var country = document.getElementById('country').value; 
   var id_region = 1;
   var ul = "puppies_search.php?act=breeder&cnt="+country+"&reg="+region+"&city="+city;	
   var mygrid2 = $("#brdtable").ingrid({ 
										url: ul,
										height: 100,
										initialLoad: true,
										paging: false,
										sorting : false,
										totalRecords: 1000,
										recordsPerPage:50,
										resizableCols: false,
										colWidths: [60,200,200,240,200],
										rowClasses: ['grid-row-style1','grid-row-style2'],
										onRowSelect: function(tr, selected){											
											var str 		= selected ? 'SELECTED' : 'UNSELECTED';
											var tr_html	= $(tr).html();											
										}										
									});
}

function ajaxpatchcity(myval){
	document.getElementById('city').value=myval;
}
//  


function SelectCity123(section, id_region, destination) {
	if (id_region != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				} else {
					if (section == 'rp') {
						destination.innerHTML = "<select style=\"width:150px\"><option>Loading data...</option></select>";
					} else {
						destination.innerHTML = "<select style=\"width:150px\" class=\"index_select\"><option>Loading data...</option></select>";
					}
				}
			}
			req.open("GET", "location.php?sec=" + section + "&sel=city&id_region=" + id_region, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}
	} else {
		destination.innerHTML = "Region is not selected";
	}
}

function CheckLogin(section, login, destination) {
	if (login != '') {
		InitXMLHttpRequest();
		// Load the result from the response page
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					destination.innerHTML = req.responseText;
				}
			}
			req.open("GET", "location.php?sec=" + section + "&sel=login&login=" + login, true);
			req.send(null);
		} else {
			destination.innerHTML = 'Browser unable to create XMLHttp Object';
		}
	} else {
		destination.innerHTML = "Nick is empty";
	}
}

function ShowTab(sel, mlink, sub, sec_par) {
	destination = document.getElementById('tab_div');
	if (sel > 6 && sub != 0) {
		if (sec_par == 2) {
			document.getElementById("sub_menu8").className='sub_tab_first';
			document.getElementById("sub_menu9").className='sub_tab';
			document.getElementById("sub_menu10").className='sub_tab';
		} else {
			document.getElementById("sub_menu7").className='sub_tab_first';
			document.getElementById("sub_menu8").className='sub_tab';
			document.getElementById("sub_menu9").className='sub_tab';
			document.getElementById("sub_menu10").className='sub_tab';
		}

		if (sel == 7) {
			document.getElementById("sub_menu"+sel).className='sub_tab_active_first';
		} else {
			if (sec_par == 2 && sel==8) {
				document.getElementById("sub_menu"+sel).className='sub_tab_active_first';
			} else {
				document.getElementById("sub_menu"+sel).className='sub_tab_active';
			}
		}

		document.getElementById("sub_link7").className='link';
		document.getElementById("sub_link8").className='link';
		document.getElementById("sub_link9").className='link';
		document.getElementById("sub_link10").className='link';
		document.getElementById("sub_link"+sel).className='text';
	} else {
		destination = document.getElementById("tab_div");
		document.getElementById("menu1").className='tab_first';
		document.getElementById("menu2").className='tab';
		document.getElementById("menu3").className='tab';
		document.getElementById("menu4").className='tab';
		document.getElementById("menu5").className='tab';
		document.getElementById("menu6").className='tab_last';

		if (sel == 1) {
			document.getElementById("menu"+sel).className='tab_active_first';
		} else if (sel == 6) {
			document.getElementById("menu"+sel).className='tab_active_last';
		} else {
			document.getElementById("menu"+sel).className='tab_active';
		}

		document.getElementById("link1").className='link';
		document.getElementById("link2").className='link';
		document.getElementById("link3").className='link';
		document.getElementById("link4").className='link';
		document.getElementById("link5").className='link';
		document.getElementById("link6").className='link';
		document.getElementById("link"+sel).className='text';
	}
	InitXMLHttpRequest();
	// Load the result from the response page
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				RunJS(destination, req.responseText);
			}
		}
		if (sel > 6 && sub != 0) {
			req.open("GET", mlink + "&sub=" + sel + "&act=ajax&action="+ sub, true);
		} else {
			req.open("GET", mlink + "&act=ajax", true);
		}
		req.send(null);
	} else {
		destination.innerHTML = 'Browser unable to create XMLHttp Object';
	}
}

function RunJS(dest, response){
	//Check user browser
	var agent=(window.navigator.appName=='Netscape')?'Firefox':'IE';
	if(agent=='IE'){
		dest.innerHTML=response;
		var arr_scripts = dest.getElementsByTagName("script");
		for(i in arr_scripts){
			var src = arr_scripts[i].src;
			if(null!=src){
				var has_question = (src.indexOf('?', 1)>0 ? true : false);
				if(0==src.length)
					arr_scripts[i].setAttribute('src', '');
				else
					arr_scripts[i].setAttribute('src', arr_scripts[i].src + (has_question==true ? '&' : '?') + '1=1');
			}
		}
	}else{
		//Mozilla
		var d=dest.parentNode;
		var d_new=document.createElement('div');

		//Set same attributes as original
		var attributes=dest.attributes;
		var len=attributes.length;

		d_new.innerHTML=response;
		for(var i=0; i<len; i++){
			d_new.setAttribute(attributes[i].name, attributes[i].value);
		}

		d.replaceChild(d_new, dest);
	}
}

function VoteAction(id_upload, vote, id_category, destination, upload_type) {
	InitXMLHttpRequest();
    if (req){
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				destination.innerHTML = req.responseText;
			} else {
				destination.innerHTML = "Loading...";
			}
		}
		req.open('GET', 'gallary.php?sel=vote&id_upload=' + id_upload + '&vote=' + vote + '&id_category=' + id_category+ '&upload_type=' + upload_type, true);
		req.send(null);
    }
    else{
       destination.innerHTML = 'Browser unable to create XMLHttp Object';
    }
    return;
}
