/***************************************
@Title: Lehigh Valley Traffic
@Page: /js/all.js
@Developer: Ted Colegrove & Jaime R. Cser 
@Support: jaime.cser@mcall.com
@Created: 1/29/07
@Modified: 
***************************************
@Notes/Comments: This page is the JS.
***************************************
@Updates: 
***************************************/


$(document).ready(function() {
	//var test = $("script[language='javascript'].attr['src']");
	//alert('test=' + test);
	$(".camera_toggle").click(function () {
		var style = $("#gallery").css("display");
	});
			   
	//$("img").pngfix();
	$(".customize").click(function() {
		new_window("http://testing.lehighvalleytraffic.com/pages/customize.php", "Customize", "650", "600", 0);		
	});
	
	$("#sf").click(function() {
		admin = $("#admin").val();
		if (admin == "") {
			admin = "0";
		}
		link_url = $("#link_url").val();
		link_title = $("#link_title").val();
		link_location = $("#link_location").val();
		link_description = $("#link_description").val();
		var string = "&admin=" + admin + "&link_url=" + link_url + "&link_title=" + link_title + "&link_location=" + link_location + "&link_description=" + link_description;
		$.ajax({
			type: "POST",
			url: "models/process-submissions.php",
			data: string,
			success: function(html){
				$("#message").show();
				$("#message").html(html);
				$("#link_url").val("");
				$("#link_title").val("");
				$("#link_location").val("");
				$("#link_description").val("");
				$("#forms_link").slideUp();
			},
			error: function(){
				$("#message").show().html("Ajax error.");
			}
		});
	});	
});



/****************************************************
Used after user displays information on marker.
Replace current information with cleared div tag.
Return Map Opacity back to full and hide the 
Information div
****************************************************/
function closeWindow() {
	$("#information").replaceWith('<div id="information"></div>');
	$("#map_canvas").css("opacity","1");
	$("#information").hide();	
}



function new_window(winURL,winNamer,winWidth,winHeight,scrollBars) { 
	var winl = (screen.width - winWidth) / 2; 
	var wint = (screen.height - winHeight) / 2; 
	var features = 'width=' + winWidth + ',height=' + winHeight + ',left=' + winl + ',top=' + wint + ',scrollbars=' + scrollBars;
	window.open(winURL,winNamer,features); 
}

/*
function customize() {
	new_window("http://testing.lehighvalleytraffic.com/pages/customize.php", "Customize", "650", "600", 0);	
}
*/
function getCookie(name) {
	var cookiename = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(cookiename) == 0) {
			cookie = c.substring(cookiename.length,c.length);
		}	
	}
}
