var xtr;
var links = {"tc" : "terms_condition.html","pp" : "privacy_policy.html","of" : "offered_services.html","jb" : "jobs.html","intrnt" : "intranets.html","cntct" : "contact_us.php", "grp_mvv" : "group.html","grp_ppl" : "group.html","grp_his" : "group.html","grp_achv" : "group.html","grp_net" : "group.html","net_aff" : "group.html","net_head" : "group.html","ln" : "links.html","na" : "news_archieve.php","site" : "site_map.html","undefined" : "welcome.html","main" : "welcome.html","offrd_inno":"offered_services.html","offrd_crw":"offered_services.html","offrd_mnpwer":"offered_services.html","offrd_trning":"offered_services.html","offrd_welfare":"offered_services.html","nwPrv":"article_preview.php"};
$(function(){
		$(".newsBox").uncorner();
		$(".newsDivision").uncorner();
		$(".mainLink").click(function()
		{
			var data={};
			window.crumb = $(this).attr("href").replace("#","");
			var x = window.crumb.split("?");
			if(xtr) xtr.abort();
			var template = "templates/";
			if(x[0]=="cntct" || x[0]=="na" || x[0]=="nwPrv") {template = "";}
			if(x[0]=="nwPrv"){data={article:x[1]}}
			window.scrollTo(0,0);
			$(".main").html("<div style='padding: 20px 0; text-align: center;'><img src='photos/ajax-loader.gif' /><br/>Loading Content please wait.</div>");	
			if(x[0]!="cntct" && x[0]!="na" && x[0]!="nwPrv")
			{
				xtr = $.ajax({
				dataType: "html",
				url: template+links[x[0]],
				timeout: 60000,
				success: function(html){
						$(".main").html(html);
						xtr= null;
					},
				error: function(){
						$(".main").html("Page loading error. Please reclick on the link after a few seconds.");
				}
				});
			}
			else
			{
				xtr = $.ajax({
				dataType: "html",
				type: "POST",
				data: data,
				url: template+links[x[0]],
				timeout: 60000,
				success: function(html){
						$(".main").html(html);
						xtr= null;
					},
				error: function(){
						$(".main").html("Page loading error. Please reclick on the link after a few seconds.");
				}
				});
			}
		});
    });
function initLoad()
{
			var data={};
			var lcode = document.location.href.split("?");
			var url=lcode[0].split("#");
			var template = "templates/";
			window.crumb = url[1];
			if(url[1]=="cntct" || url[1]=="na" || url[1]=="nwPrv") template = "";
			if(url[1]=="nwPrv"){data={article:lcode[1]}}
			
			window.scrollTo(0,0);
			$(".main").html("<div style='padding: 20px 0; text-align: center;'><img src='photos/ajax-loader.gif' /><br/>Loading Content please wait.</div>");	
			if(url[1]!="cntct" && url[1]!="na" && url[1]!="nwPrv")
			{
				xtr = $.ajax({
				dataType: "html",
				url: template+links[url[1]],
				timeout: 60000,
				success: function(html){
						$(".main").html(html);	
						xtr= null;		
					},
				error: function(){
						$(".main").html("Page loading error. Please reclick on the link after a few seconds.");
					}
				});
			}
			else
			{
				xtr = $.ajax({
				dataType: "html",
				url: template+links[url[1]],
				timeout: 60000,
				type: "POST",
				data: data,
				success: function(html){
						$(".main").html(html);	
						xtr= null;		
					},
				error: function(){
						$(".main").html("Page loading error. Please reclick on the link after a few seconds.");
					}
				});	
			}
}

function validateEmailNewsLetter(objName) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.getElementById(objName).value;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
      return false;
   }
   else
   {
	   var x = confirm("Do want you want to subscribe to newsletter?");
	   if(x)
	   {
		    var emailAddress = "mdaemon@elvictor.com";
			document.getElementById("formNewsLetter").action = "mailto:"+emailAddress+"?subject=SUBSCRIBE NEWSLETTER@ELVICTOR.COM";
			return true;
		}
		else{
			return false;			
		}
   }
}
//BOOKMARK

function CreateBookmarkLink() { title = "Webpage Title";
	// Blogger - Replace with <$BlogItemTitle$>
	// MovableType - Replace with <$MTEntryTitle$> 
	url = "Webpage URL";  
	// Blogger - Replace with <$BlogItemPermalinkURL$>
	// MovableType - Replace with <$MTEntryPermalink$>
	// WordPress - <?php bloginfo('url'); ?>
	if(window.chrome)
	{
		alert("Press CTRL+D after pressing the OK button to bookmark this page.");
	}
	else if (window.sidebar) { 
	// Mozilla Firefox Bookmark		
		window.sidebar.addPanel(document.title, location.href,"");	
	} 
	else if( window.external ) { 
	// IE Favorite		
		window.external.AddFavorite( location.href, document.title); 
	}	
	else if(window.opera && window.print) { 
	// Opera Hotlist	
		alert("Press CTRL+D to bookmark this page.");	
	return true; 
	}
}
