function OBJ_Search_Symbol()
{

	this.show_symbol = function(image, x, y, code, competition_id, competition_type)
	{
		document.write('<img src="http://i.tvnet.lv/search_symbol/'+image+'" style="position:absolute; z-index:9000; top:'+y+'px; left:'+x+'px; cursor: pointer;" onclick="');

		if(competition_type==1)
			document.write('SEARCH_SYMBOL.open_register_form(this,\''+code+'\', '+competition_id+');');
		else
			document.write('SEARCH_SYMBOL.show_message(\''+code+'\', '+competition_id+');');

		document.write('" />');
	}

	this.show_message = function(code,competition_id)
	{
		var reg_form=window.open('/search_symbol.html','' ,' height=170, width=340 ,left=200 ,top=200, toolbar=no, menubar=no, location=no, status=no, directories=no');
        reg_form.document.write('<style type="text/css" > ');
        reg_form.document.write('label { font-weight: bold; } ');
        reg_form.document.write('body { color:#343434; font-family:Verdana,Geneva,Helvetica,Arial,sans-serif; font-size: 12px; } ');
        reg_form.document.write('.text_field { border:0.083em solid #999999; margin-bottom:0.25em; padding:0.25em; -moz-border-radius:4px 4px 4px 4px; -webkit-border-radius:4px 4px 4px 4px; width: 250px; } ');
        reg_form.document.write('.orange_button { -moz-border-radius:4px 4px 4px 4px; -webkit-border-radius:4px 4px 4px 4px; background-color:#FF6600; border:0.0833em solid #FF6600; color:#FFFFFF; padding:0.167em; margin-left: 20px; } ');
        reg_form.document.write('.center_content { text-align: center; } ');
        reg_form.document.write('.red { color: #FF6600; } ');
        reg_form.document.write('a, a:hover { color: #FF6600; } ');
        reg_form.document.write('</style> ');

        reg_form.document.write('<p id="search_symbol_info_text" class="center_content">');
        reg_form.document.write('PAVASARA KONKURSS<br />');
        reg_form.document.write('<b>' + code + '</b><br />');
        reg_form.document.write('Plašāk par konkursu lasiet <a href="javascript:;" onclick="window.parent.location.assign(\'http://www.tvnet.lv/akcija/irobot\');">http://www.tvnet.lv/akcija/irobot</a>');
        reg_form.document.write('</p>');

        reg_form.document.write('<div class="center_content">');
        reg_form.document.write('<input class="orange_button" type="button" onclick="self.close();" value="Aizvērt" >');
        reg_form.document.write('</div>');

        reg_form.document.close();
	}

	this.open_register_form = function(obj,code,competition_id)
	{
		//obj.style.display='none';

		var reg_form=window.open('/search_symbol.html','' ,' height=170, width=340 ,left=200 ,top=200, toolbar=no, menubar=no, location=no, status=no, directories=no');
        reg_form.document.write('<scr' + 'ipt type="text/javascript" src="/assets/js/search_symbol.js"></script>');
        reg_form.document.write('<scr' + 'ipt type="text/javascript" src="/assets/js/jquery-1.4.2.min.js"></script>');
        reg_form.document.write('<style type="text/css" > ');
        reg_form.document.write('label { font-weight: bold; } ');
        reg_form.document.write('body { color:#343434; font-family:Verdana,Geneva,Helvetica,Arial,sans-serif; font-size: 12px; } ');
        reg_form.document.write('.text_field { border:0.083em solid #999999; margin-bottom:0.25em; padding:0.25em; -moz-border-radius:4px 4px 4px 4px; -webkit-border-radius:4px 4px 4px 4px; width: 250px; } ');
        reg_form.document.write('.orange_button { -moz-border-radius:4px 4px 4px 4px; -webkit-border-radius:4px 4px 4px 4px; background-color:#FF6600; border:0.0833em solid #FF6600; color:#FFFFFF; padding:0.167em; margin-left: 20px; } ');
        reg_form.document.write('.center_content { text-align: center; } ');
        reg_form.document.write('.red { color: #FF6600; } ');
        reg_form.document.write('a, a:hover { color: #FF6600; } ');
        reg_form.document.write('</style> ');

        reg_form.document.write('<p id="search_symbol_info_text" class="center_content">');
        reg_form.document.write('<b>Ievadi savu e-pasta adresi lai piereģistrētu atrasto RAMMSTEIN logo!</b><br />');
        reg_form.document.write('Klausies arī "Radio SWH Rock" un uzzini kā vari piedalīties lielā komplekta izlozē. Visa informācija <a href="http://www.radioswh.lv/swhrock/page.php?id=322" target="_blank" >„Radio SWH Rock” mājas lapā.</a>');
        reg_form.document.write('</p>');

        reg_form.document.write('<form method="post">');
        reg_form.document.write('<input type="hidden" name="code" id="code" value="'+code+'">');

        reg_form.document.write('<div class="bottom_margin center_content">');
        reg_form.document.write('<label for="e_mail">e-pasts:</lable> <input class="text_field" type="text" name="e_mail" id="e_mail" >');
        reg_form.document.write('</div>');

        reg_form.document.write('<div class="center_content">');
        reg_form.document.write('<input class="orange_button" type="button" onclick="SEARCH_SYMBOL.send();" value="Sūtīt" >');
        reg_form.document.write('<input class="orange_button" type="button" onclick="self.close();" value="Aizvērt" >');
        reg_form.document.write('</div>');

        reg_form.document.write('</form>');

        reg_form.document.close();
	}


	this.send = function()
	{
    	var check = false;

		var info_text = $('#search_symbol_info_text');
 		var code = $('#code').val();
 		var e_mail = $('#e_mail').val();

		// chect wether all fields filled
		if(code.length > 0 && e_mail.length > 0)
			check = true;
		else
			check = false;

		if(check == true)
		{
			// post data and save success message
			$.post( '/ajax/saveSearchSymbol',
			{ code: code, e_mail: e_mail },
  			function(data){	if(data == 'success') info_text.html('<em>Veiksmīgi piereģistrēts logo!</em>'); else info_text.html('<em class="red"><b>Kļūda!</b> Šo logo esat jau iepriekš piereģistrējis!</em>'); },
  			"html");
		}
		else
		{
			// show error message
			info_text.html('<em class="red"><b>Kļūda!</b> Pārbaudiet vai e-pasts ievadīts korekti!</em>');
		}

	}
}

var SEARCH_SYMBOL = new OBJ_Search_Symbol();


