// JavaScript Document


$(document).ready(init);
function init()
{

	//if ($("#cont01").get(0)) map();
	if ($("#cont02").get(0)) {  
		points_();
		showcontacts();
	}
	if ($("#clrbtn").get(0)) clear_fields();
	limitText();
}


function limitText() {
	$("textarea")
		.keydown (
			function(){
				if (this.value.length > 1000) 
					this.value = this.value.substring(0, 1000);
			})
	    .keyup (function(){
				if (this.value.length > 1000) 
					this.value = this.value.substring(0, 1000);
			})
	
}

function map(){

	$("#cont01 > ul > li").mouseover(
		function() {
					
				$(this).find("img").css("display", "block");
			}
	)
	
	$("#cont01 > ul > li").mouseout(
		function() {
				
				$(this).find("img").css("display", "none");
			}
	)
	
}

function showcontacts(){
	$("#cont02").find("ul").each(function(){
				this.className = '';	
				this.parentNode.className='st02';
												
	})	
	
}
function points_() {
	var obj = null;
	
	$("#cont02 > ul > li > p").click(
		function (){
				$(this.parentNode).find("ul").each(
					function () {
						if (this.className=='hide') {
										this.className = '';
										//$(this.parentNode).css('background', 'url(../../_images/bull01.gif) no-repeat left 3px');
										this.parentNode.className='st02';
										obj = $("#cont02").get(0).obj;
										if ((obj!=this )&&(obj!=null)) {
												obj.className = 'hide';
												//$(obj.parentNode).css('background', 'url(../../_images/bull02.gif) no-repeat left 3px');
												obj.parentNode.className='st01';
										}
										$("#cont02").get(0).obj = this;
							}
							else {
								this.className = 'hide';
								//$(this.parentNode).css('background', 'url(../../_images/bull02.gif) no-repeat left 3px');
								this.parentNode.className='st01';
								$("#cont02").get(0).obj = null;
							}
				    }								   
				)
			
			}							  
										  
	)
	
	$("a[@hint]").mouseover(
			function (){
					var hint = $(this).attr("hint");
					
					var xx = $(this.parentNode).css("left");
					var yy = $(this.parentNode).css("top");
					xx = xx.substr(0, xx.length - 2)*1+10;
					yy = yy.substr(0, yy.length - 2)*1+10;
					
			
					if (hint.indexOf('Lahore')!=-1) { xx = xx-50;yy = yy+10; }
					
					$("#hint").text(hint);
					$("#hint").css("left", xx+"px");
					$("#hint").css("top", yy+"px");
					$("#hint").css("display", "block");
						
					
				}
	)
	$("a[@hint]").mouseout(
			function (){
					$("#hint").text('');
					$("#hint").css("display", "none");
				}
	)
	
	
}

function clear_fields(){
	
	$("#clrbtn").click(
		 function () { 
		 /*$("form").each(function() {this.reset();}); */
			$("textarea").text('');
			$("input:text").each(function () {if (!$(this).attr('disabled')) $(this).attr('value', '');}) 
			$("input:radio").each(function() {this.removeAttribute("checked")})
			$("option").each(function() {this.removeAttribute("selected")})
			$("input:checkbox").each(function() {
											  	/*var newAttr = document.createAttribute("checked");
    											newAttr.nodeValue = "checked";
    											this.setAttributeNode(newAttr);*/ 
												this.removeAttribute("checked"); 
												})
			
		}					   
	)
}




